Skip to content

Commit 755f22d

Browse files
committed
Add tests for deprecation warnings
1 parent 1a0f60b commit 755f22d

5 files changed

Lines changed: 46 additions & 4 deletions

File tree

CI/SCRIPTS/test_others.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
from eoreader import utils
1515
from eoreader.bands import (
16+
AFRI_1_6,
1617
BLUE,
1718
CA,
1819
CLOUDS,
1920
DEM,
2021
GREEN,
22+
GREEN1,
2123
HH,
2224
HILLSHADE,
2325
HV,
@@ -419,3 +421,33 @@ def test_windowed_reading():
419421
# The arrays shouldn't be equal (some cleaning is done)
420422
with pytest.raises(AssertionError):
421423
np.testing.assert_array_equal(red_raw.data, red_clean.data)
424+
425+
426+
def test_deprecation():
427+
"""Test deprecation warning"""
428+
429+
opt_stack = others_path() / "20200310T030415_WV02_Ortho_BGRN_STK.tif"
430+
prod_green1 = READER.open(
431+
opt_stack,
432+
custom=True,
433+
sensor_type=SensorType.OPTICAL,
434+
pixel_size=2.0,
435+
band_map={GREEN1: 1, RED: 2, BLUE: 3, NIR: 4, SWIR_1: 5},
436+
)
437+
window = Window(200, 500, 200, 500)
438+
439+
# Check deprecation for GREEN1
440+
with pytest.deprecated_call():
441+
to_band("GREEN1")
442+
with pytest.deprecated_call():
443+
prod_green1.load("GREEN1", window=window)
444+
with pytest.deprecated_call():
445+
prod_green1.load(GREEN1, window=window)
446+
447+
# Check deprecation for deprecated spectral indices
448+
with pytest.deprecated_call():
449+
prod_green1.load(AFRI_1_6, window=window)
450+
451+
# Check deprecation for resolution keyword
452+
with pytest.deprecated_call():
453+
prod_green1.load(SWIR_1, resolution=2.0, window=window)

eoreader/bands/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,15 @@ def to_band(to_convert: Union[list, BandNames, str]) -> list:
449449
if band_or_idx:
450450
band_list.append(band_or_idx)
451451
else:
452-
raise _ite(f"Unknown band or index: {tc}")
452+
if tc == "GREEN1":
453+
from sertit import logs
454+
455+
logs.deprecation_warning(
456+
"`GREEN1` is deprecated in favor of `GREEN_1`. `GREEN1` will be removed in a future release."
457+
)
458+
band_list.append(GREEN_1)
459+
else:
460+
raise _ite(f"Unknown band or index: {tc}")
453461

454462
return band_list
455463

eoreader/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ def read(
182182
size=size,
183183
window=window,
184184
chunks=chunks,
185-
**_prune_keywords(additional_keywords=["window", "chunks"], **kwargs),
185+
**_prune_keywords(
186+
additional_keywords=["window", "chunks", "resolution"], **kwargs
187+
),
186188
)
187189

188190
# In EOReader, we don't care about the band coordinate of a band loaded from a stack.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ spyndex>=0.3.0
4040
pystac[validation]
4141

4242
# SERTIT libs
43-
sertit[full]>=1.27.0
43+
sertit[full]>=1.27.3
4444

4545
# Optimizations
4646
dask[complete]>=2021.10.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"xarray>=0.18.0",
3434
"rioxarray>=0.10.0",
3535
"geopandas>=0.11.0",
36-
"sertit[full]>=1.27.0",
36+
"sertit[full]>=1.27.3",
3737
"spyndex>=0.3.0",
3838
"pyresample",
3939
"zarr",

0 commit comments

Comments
 (0)