Skip to content

Commit df8bbe8

Browse files
authored
Release 1.5.7, Merge pull request #800 from sentinel-hub/develop
Release 1.5.7
2 parents 303e758 + 5a1e9e0 commit df8bbe8

File tree

12 files changed

+39
-34
lines changed

12 files changed

+39
-34
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ repos:
1313
- id: debug-statements
1414

1515
- repo: https://github.com/psf/black
16-
rev: 24.4.2
16+
rev: 24.8.0
1717
hooks:
1818
- id: black
1919
language_version: python3
2020

2121
- repo: https://github.com/charliermarsh/ruff-pre-commit
22-
rev: "v0.4.9"
22+
rev: "v0.6.8"
2323
hooks:
2424
- id: ruff
2525

2626
- repo: https://github.com/nbQA-dev/nbQA
27-
rev: 1.8.5
27+
rev: 1.8.7
2828
hooks:
2929
- id: nbqa-black
3030
- id: nbqa-ruff

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [Version 1.5.7] - 2024-09-27
2+
3+
- Remove `numpy<2` restriction.
4+
15
## [Version 1.5.6] - 2024-06-26
26

37
- Limit `geopandas` version to < 1.0.0

eolearn/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Main module of the `eolearn` package."""
22

3-
__version__ = "1.5.6"
3+
__version__ = "1.5.7"
44

55
import importlib.util
66
import warnings

eolearn/core/constants.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def _warn_and_adjust(name: T) -> T:
4646
class EnumWithDeprecations(EnumMeta):
4747
"""A custom EnumMeta class for catching the deprecated Enum members of the FeatureType Enum class."""
4848

49-
def __getattribute__(cls, name: str) -> Any: # noqa: N805
49+
def __getattribute__(cls, name: str) -> Any:
5050
return super().__getattribute__(_warn_and_adjust(name))
5151

52-
def __getitem__(cls, name: str) -> Any: # noqa: N805
52+
def __getitem__(cls, name: str) -> Any:
5353
return super().__getitem__(_warn_and_adjust(name))
5454

55-
def __call__(cls, value: str, *args: Any, **kwargs: Any) -> Any: # noqa: N805
55+
def __call__(cls, value: str, *args: Any, **kwargs: Any) -> Any:
5656
return super().__call__(_warn_and_adjust(value), *args, **kwargs)
5757

5858

@@ -238,13 +238,13 @@ def _warn_and_adjust_permissions(name: T) -> T:
238238
class PermissionsWithDeprecations(EnumMeta):
239239
"""A custom EnumMeta class for catching the deprecated Enum members of the OverwritePermission Enum class."""
240240

241-
def __getattribute__(cls, name: str) -> Any: # noqa: N805
241+
def __getattribute__(cls, name: str) -> Any:
242242
return super().__getattribute__(_warn_and_adjust_permissions(name))
243243

244-
def __getitem__(cls, name: str) -> Any: # noqa: N805
244+
def __getitem__(cls, name: str) -> Any:
245245
return super().__getitem__(_warn_and_adjust_permissions(name))
246246

247-
def __call__(cls, value: str, *args: Any, **kwargs: Any) -> Any: # noqa: N805
247+
def __call__(cls, value: str, *args: Any, **kwargs: Any) -> Any:
248248
return super().__call__(_warn_and_adjust_permissions(value), *args, **kwargs)
249249

250250

eolearn/core/utils/raster.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def constant_pad( # noqa: C901
112112
else:
113113
raise ValueError("Padding rule for columns not supported. Choose between even, left or right!")
114114

115-
return np.lib.pad(
115+
return np.pad(
116116
array,
117117
((row_padding_up, row_padding_down), (col_padding_left, col_padding_right)),
118118
"constant",

eolearn/features/utils.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import warnings
1313
from enum import Enum
1414
from functools import partial
15-
from typing import TYPE_CHECKING
15+
from typing import TYPE_CHECKING, Callable
1616

1717
import cv2
1818
import numpy as np
@@ -86,15 +86,17 @@ class ResizeLib(Enum):
8686

8787
def get_compatible_dtype(self, dtype: np.dtype | type) -> np.dtype:
8888
"""Returns a suitable dtype with which the library can work. Warns if information loss could occur."""
89+
lossless: dict[type, type]
90+
infoloss: dict[type, type]
8991
if self is ResizeLib.CV2:
9092
lossless = {bool: np.uint8, np.float16: np.float32}
9193
infoloss = {x: np.int32 for x in (np.uint32, np.int64, np.uint64, int)}
9294
if self is ResizeLib.PIL:
9395
lossless = {np.float16: np.float32}
9496
infoloss = {x: np.int32 for x in (np.uint16, np.uint32, np.int64, np.uint64, int)}
9597

96-
lossless_casts = {np.dtype(k): np.dtype(v) for k, v in lossless.items()}
97-
infoloss_casts = {np.dtype(k): np.dtype(v) for k, v in infoloss.items()}
98+
lossless_casts: dict[np.dtype, np.dtype] = {np.dtype(k): np.dtype(v) for k, v in lossless.items()}
99+
infoloss_casts: dict[np.dtype, np.dtype] = {np.dtype(k): np.dtype(v) for k, v in infoloss.items()}
98100
return self._extract_compatible_dtype(dtype, lossless_casts, infoloss_casts)
99101

100102
@staticmethod
@@ -159,14 +161,11 @@ def spatially_resize_image(
159161
old_dtype, new_dtype = data.dtype, resize_library.get_compatible_dtype(data.dtype)
160162
data = data.astype(new_dtype)
161163

164+
resize_function: Callable[[np.ndarray], np.ndarray]
162165
if resize_library is ResizeLib.CV2:
163166
resize_function = partial(cv2.resize, dsize=size, interpolation=resize_method.get_cv2_method(data.dtype))
164167
else:
165-
resize_function = partial(
166-
_pil_resize_ndarray, # type: ignore[arg-type]
167-
size=size,
168-
method=resize_method.get_pil_method(),
169-
)
168+
resize_function = partial(_pil_resize_ndarray, size=size, method=resize_method.get_pil_method())
170169

171170
resized_data = _apply_to_spatial_axes(resize_function, data, spatial_axes)
172171

eolearn/visualization/eopatch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def _provide_axes(self, *, nrows: int, ncols: int, title: str | None = None, **s
330330
**subplot_kwargs,
331331
)
332332
if title and self.config.show_title:
333-
title_kwargs = {"t": title, "fontsize": 16, "y": 1.0, **self.config.title_kwargs}
333+
title_kwargs: dict[str, Any] = {"t": title, "fontsize": 16, "y": 1.0, **self.config.title_kwargs}
334334
fig.suptitle(**title_kwargs)
335335

336336
fig.subplots_adjust(wspace=0.06, hspace=0.06)

examples/land-cover-map/SI_LULC_pipeline.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@
15591559
"source": [
15601560
"class_labels = np.unique(labels_test)\n",
15611561
"class_names = [lulc_type.name for lulc_type in LULC]\n",
1562-
"mask = np.in1d(predicted_labels_test, labels_test)\n",
1562+
"mask = np.in1d(predicted_labels_test, labels_test) # noqa: NPY201\n",
15631563
"predictions = predicted_labels_test[mask]\n",
15641564
"true_labels = labels_test[mask]\n",
15651565
"\n",

pyproject.toml

+11-9
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ dependencies = [
4747
"boto3",
4848
"fs",
4949
"fs-s3fs",
50-
"geopandas>=0.11.0,<1",
51-
"numpy>=1.20.0,<2",
50+
"geopandas>=0.14.4,<1; python_version>='3.9'",
51+
"geopandas>=0.11.0,<1; python_version<'3.9'",
52+
"numpy>=1.20.0",
5253
"python-dateutil",
5354
"sentinelhub>=3.9.0",
5455
"tqdm>=4.27",
@@ -57,7 +58,8 @@ dependencies = [
5758
"affine",
5859
"rasterio>=1.3.8",
5960
"shapely",
60-
"fiona>=1.8.18",
61+
"fiona>=1.8.18; python_version>='3.9'",
62+
"fiona>=1.8.18,<1.10; python_version<'3.9'",
6163
]
6264

6365
[project.optional-dependencies]
@@ -104,7 +106,7 @@ preview = true
104106
[tool.ruff]
105107
line-length = 120
106108
target-version = "py38"
107-
select = [
109+
lint.select = [
108110
"F", # pyflakes
109111
"E", # pycodestyle
110112
"W", # pycodestyle
@@ -137,15 +139,15 @@ select = [
137139
"RUF", # ruff rules
138140
]
139141
fix = true
140-
fixable = [
142+
lint.fixable = [
141143
"I", # sort imports
142144
"F401", # remove redundant imports
143145
"UP007", # use new-style union type annotations
144146
"UP006", # use new-style built-in type annotations
145147
"UP037", # remove quotes around types when not necessary
146148
"FA100", # import future annotations where necessary (not autofixable ATM)
147149
]
148-
ignore = [
150+
lint.ignore = [
149151
"C408", # complains about `dict()` calls, we use them to avoid too many " in the code
150152
"SIM108", # tries to aggresively inline `if`, not always readable
151153
"A003", # complains when ATTRIBUTES shadow builtins, we have objects that implement `filter` and such
@@ -156,17 +158,17 @@ ignore = [
156158
"B028", # always demands a stacklevel argument when warning
157159
"PT011", # complains for `pytest.raises(ValueError)` but we use it a lot
158160
]
159-
per-file-ignores = { "__init__.py" = [
161+
lint.per-file-ignores = { "__init__.py" = [
160162
"F401",
161163
"I002",
162164
], "conf.py" = [
163165
"I002",
164166
"FA100",
165167
] }
166-
exclude = [".git", "__pycache__", "build", "dist"]
168+
exclude = [".git", "__pycache__", "build", "dist", "*.ipynb"]
167169

168170

169-
[tool.ruff.isort]
171+
[tool.ruff.lint.isort]
170172
required-imports = ["from __future__ import annotations"]
171173
section-order = [
172174
"future",

tests/features/test_features_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_spatially_resize_image_new_size(
1515
):
1616
"""Test that all methods and backends are able to downscale and upscale images of various dtypes."""
1717
if library is ResizeLib.CV2: # noqa: SIM102
18-
if np.issubdtype(dtype, np.integer) and method is ResizeMethod.CUBIC or dtype == bool:
18+
if np.issubdtype(dtype, np.integer) and method is ResizeMethod.CUBIC or dtype is bool:
1919
return
2020

2121
old_shape = (111, 111)

tests/io/test_sentinelhub_process.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def calculate_stats(array):
6262
return np.round(np.array(values), 4)
6363

6464

65-
@pytest.mark.sh_integration()
65+
@pytest.mark.sh_integration
6666
class TestProcessingIO:
6767
"""Test cases for SentinelHubInputTask"""
6868

@@ -554,7 +554,7 @@ def test_no_data_evalscript_task_request(self):
554554
assert masks.shape == (0, 101, 99, 1)
555555

556556

557-
@pytest.mark.sh_integration()
557+
@pytest.mark.sh_integration
558558
class TestSentinelHubInputTaskDataCollections:
559559
"""Integration tests for all supported data collections"""
560560

tests/visualization/test_eopatch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def eopatch_fixture():
4747
((FeatureType.VECTOR_TIMELESS, "LULC"), {}),
4848
],
4949
)
50-
@pytest.mark.sh_integration()
50+
@pytest.mark.sh_integration
5151
def test_eopatch_plot(eopatch: EOPatch, feature, params):
5252
"""A simple test of EOPatch plotting for different features."""
5353
# We reduce width and height otherwise running matplotlib.pyplot.subplots in combination with pytest would

0 commit comments

Comments
 (0)