diff --git a/.github/workflows/test-python-codebase-on-main.yml b/.github/workflows/test-python-codebase-on-main.yml index 71fba1226..ddd6cf751 100644 --- a/.github/workflows/test-python-codebase-on-main.yml +++ b/.github/workflows/test-python-codebase-on-main.yml @@ -43,5 +43,5 @@ jobs: - name: Run Pytests run: | source .venv/bin/activate - pdm run -v pytest -m "ci" --cov=packages tests + pytest -m "ci" --cov=packages tests coverage report diff --git a/.gitignore b/.gitignore index f717adf9c..5cf25d74b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ test-tmp/ hidden/ packages/docs/docs/api-reference/ui cli.sh +.pdm-python # runtime data pids diff --git a/packages/core/threads/helios_thread.py b/packages/core/threads/helios_thread.py index 0eca3bf30..a3ed94e97 100644 --- a/packages/core/threads/helios_thread.py +++ b/packages/core/threads/helios_thread.py @@ -132,7 +132,9 @@ def take_image( for _ in range(retries + 1): ret, frame = self.camera.read() if ret: - if trow_away_white_images and np.mean(frame) > 240: + if trow_away_white_images and np.mean( + frame # type: ignore + ) > 240: # image is mostly white continue return np.array(frame) diff --git a/packages/core/utils/helios_image_processing.py b/packages/core/utils/helios_image_processing.py index 1bd72cedb..2f6f1e9c0 100644 --- a/packages/core/utils/helios_image_processing.py +++ b/packages/core/utils/helios_image_processing.py @@ -71,7 +71,7 @@ def _get_binary_mask(frame: np.ndarray[Any, Any]) -> np.ndarray[Any, Any]: _, kmeans_labels, kmeans_centers = cv.kmeans( data=np.array(blurred_image.flatten(), dtype=np.float32), K=2, - bestLabels=None, + bestLabels=None, # type: ignore criteria=( cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 10, 1.0 ), @@ -123,7 +123,7 @@ def _get_circle_location( # get the circle that is closest to the image center x, y, r = min( - np.round(circles[0, :]).astype("int"), + np.round(circles[0, :]).astype("int"), # type: ignore key=lambda c: math.pow(c[0] - (image_width * 0.5), 2) # type: ignore + pow(c[1] - (image_height * 0.5), 2), @@ -226,17 +226,22 @@ def get_edge_fraction( ) # blacken the outer 10% of the circle radius - edges_only_dilated *= HeliosImageProcessing._get_circle_mask( - edges_only_dilated.shape, round(circle_r * 0.9), circle_cx, - circle_cy + edges_only_dilated *= HeliosImageProcessing._get_circle_mask( # type: ignore + edges_only_dilated.shape, # type: ignore + round(circle_r * 0.9), + circle_cx, + circle_cy, ) # determine how many pixels inside the circle are made up of "edge pixels" pixels_inside_circle: int = np.sum(3.141592 * pow(circle_r * 0.9, 2)) edge_fraction: float = 0 if pixels_inside_circle != 0: - edge_fraction = round((np.sum(edges_only_dilated) / 255) / - pixels_inside_circle, 6) + edge_fraction = round( + (np.sum(edges_only_dilated) / 255) / # type: ignore + pixels_inside_circle, + 6 + ) if save_images_to_archive or save_current_image: now = datetime.datetime.now() diff --git a/pyproject.toml b/pyproject.toml index d60a34046..719c93af8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,7 @@ spaces_around_subscript_colon = true [tool.mypy] strict = true implicit_reexport = true +warn_unused_ignores = false plugins = ["pydantic.mypy"] [[tool.mypy.overrides]] diff --git a/tests/utils/test_astronomy.py b/tests/utils/test_astronomy.py index 273266d18..3d3bb0d97 100644 --- a/tests/utils/test_astronomy.py +++ b/tests/utils/test_astronomy.py @@ -47,7 +47,7 @@ def test_astronomy(sample_config: types.Config) -> None: sample_config, lat=48.137154, lon=11.576124, alt=515 ) assert isinstance(e2, float) - assert abs(e1 - e2) < 1e-3 + assert abs(e1 - e2) < 1e-2 # generate a random datetime for every year between 2020 and 2050 # and test whether the elevation is correctly computed