diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8ee6872..1948c24 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: end-of-file-fixer - id: requirements-txt-fixer @@ -13,18 +13,18 @@ repos: - id: debug-statements - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.12.1 hooks: - id: black language_version: python3 - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.0.269" + rev: "v0.1.11" hooks: - id: ruff - repo: https://github.com/nbQA-dev/nbQA - rev: 1.6.3 + rev: 1.7.1 hooks: - id: nbqa-black - id: nbqa-ruff diff --git a/pyproject.toml b/pyproject.toml index 328a7d2..55eae10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ classifiers = [ ] dependencies = [ "lightgbm>=2.0.11", - "numpy>=1.13.3", + "numpy>=1.13.3,<2", "opencv-python-headless", "sentinelhub>=3.9.0", "typing_extensions", diff --git a/s2cloudless/__init__.py b/s2cloudless/__init__.py index 0bce1e1..abba849 100644 --- a/s2cloudless/__init__.py +++ b/s2cloudless/__init__.py @@ -4,4 +4,4 @@ from .pixel_classifier import PixelClassifier from .utils import download_bands_and_valid_data_mask -__version__ = "1.7.1" +__version__ = "1.7.2" diff --git a/s2cloudless/cloud_detector.py b/s2cloudless/cloud_detector.py index 33f690f..e3a50ca 100644 --- a/s2cloudless/cloud_detector.py +++ b/s2cloudless/cloud_detector.py @@ -1,4 +1,5 @@ """Module for pixel-based classification on Sentinel-2 L1C imagery.""" + from __future__ import annotations import os diff --git a/s2cloudless/pixel_classifier.py b/s2cloudless/pixel_classifier.py index 6ec6e7d..2c556ef 100644 --- a/s2cloudless/pixel_classifier.py +++ b/s2cloudless/pixel_classifier.py @@ -1,4 +1,5 @@ """Module for pixel-based classifiers.""" + from __future__ import annotations from typing import Any, Protocol @@ -75,8 +76,8 @@ def image_predict_proba(self, data: np.ndarray, **kwargs: Any) -> np.ndarray: pixels = data.reshape((-1, data.shape[-1])) if isinstance(self.classifier, Booster): - probabilities = self.classifier.predict(pixels, **kwargs) - probabilities = np.vstack((1.0 - probabilities, probabilities)).transpose() + proba = self.classifier.predict(pixels, **kwargs) + probabilities = np.vstack([1.0 - proba, proba]).transpose() # type: ignore[operator, list-item] else: probabilities = self.classifier.predict_proba(pixels, **kwargs) diff --git a/s2cloudless/utils.py b/s2cloudless/utils.py index 5e2ebb2..ce09219 100644 --- a/s2cloudless/utils.py +++ b/s2cloudless/utils.py @@ -76,6 +76,6 @@ def download_bands_and_valid_data_mask( def cv2_disk(radius: int) -> np.ndarray: """Recreates the disk structural element from skimage.morphology using OpenCV.""" - return cv2.circle( + return cv2.circle( # type: ignore[call-overload] np.zeros((radius * 2 + 1, radius * 2 + 1), dtype=np.uint8), (radius, radius), radius, color=1, thickness=-1 ) diff --git a/tests/test_utils.py b/tests/test_utils.py index bec922a..fd9b3ad 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,6 @@ +from __future__ import annotations + import datetime as dt -from typing import Tuple import numpy as np import pytest @@ -46,7 +47,7 @@ ], ) @pytest.mark.sh_integration() -def test_download_bands_and_valid_data_mask(test_input: dict, expected_shape: Tuple[int, int, int]) -> None: +def test_download_bands_and_valid_data_mask(test_input: dict, expected_shape: tuple[int, int, int]) -> None: bands, mask = download_bands_and_valid_data_mask(**test_input) assert bands.shape == expected_shape assert bands.dtype == np.float32