Skip to content

Commit

Permalink
update test to avoid future deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Jul 25, 2023
1 parent 23617bc commit 1b96e09
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
28 changes: 14 additions & 14 deletions tests/test_cbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ def test_AWSPDS_CBERSReader_CB4_MUX(rio):
cbers.info(bands="BAND5")

metadata = cbers.info(bands="B5")
assert len(metadata["band_metadata"]) == 1
assert metadata["band_descriptions"] == [("B5", "")]
assert len(metadata.band_metadata) == 1
assert metadata.band_descriptions == [("B5", "")]

metadata = cbers.info(bands=cbers.bands)
assert len(metadata["band_metadata"]) == 4
assert metadata["band_descriptions"] == [
assert len(metadata.band_metadata) == 4
assert metadata.band_descriptions == [
("B5", ""),
("B6", ""),
("B7", ""),
Expand All @@ -90,11 +90,11 @@ def test_AWSPDS_CBERSReader_CB4_MUX(rio):

stats = cbers.statistics(bands="B5")
assert len(stats.items()) == 1
assert stats["B5"]["percentile_2"]
assert stats["B5"]["percentile_98"]
assert stats["B5"].percentile_2
assert stats["B5"].percentile_98

stats = cbers.statistics(bands=cbers.bands, hist_options={"bins": 20})
assert len(stats["B5"]["histogram"][0]) == 20
assert len(stats["B5"].histogram[0]) == 20

tile_z = 10
tile_x = 664
Expand Down Expand Up @@ -208,12 +208,12 @@ def test_AWSPDS_CBERSReader_CB4A_MUX(rio):
cbers.info(bands="BAND5")

metadata = cbers.info(bands="B5")
assert len(metadata["band_metadata"]) == 1
assert metadata["band_descriptions"] == [("B5", "")]
assert len(metadata.band_metadata) == 1
assert metadata.band_descriptions == [("B5", "")]

metadata = cbers.info(bands=cbers.bands)
assert len(metadata["band_metadata"]) == 4
assert metadata["band_descriptions"] == [
assert len(metadata.band_metadata) == 4
assert metadata.band_descriptions == [
("B5", ""),
("B6", ""),
("B7", ""),
Expand All @@ -226,11 +226,11 @@ def test_AWSPDS_CBERSReader_CB4A_MUX(rio):

stats = cbers.statistics(bands="B5")
assert len(stats.items()) == 1
assert stats["B5"]["percentile_2"]
assert stats["B5"]["percentile_98"]
assert stats["B5"].percentile_2
assert stats["B5"].percentile_98

stats = cbers.statistics(bands=cbers.bands, hist_options={"bins": 20})
assert len(stats["B5"]["histogram"][0]) == 20
assert len(stats["B5"].histogram[0]) == 20

tile_z = 10
tile_x = 385
Expand Down
16 changes: 8 additions & 8 deletions tests/test_landsat.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,35 +594,35 @@ def test_LandsatC2L2Reader(rio, fetch):
landsat.info(bands="BAND5")

metadata = landsat.info(bands="SR_B5")
assert len(metadata["band_metadata"]) == 1
assert metadata["band_descriptions"] == [("SR_B5", "")]
assert len(metadata.band_metadata) == 1
assert metadata.band_descriptions == [("SR_B5", "")]

metadata = landsat.info(bands=landsat.bands)
assert len(metadata["band_metadata"]) == len(OLI_SR_BANDS + TIRS_ST_BANDS)
assert len(metadata.band_metadata) == len(OLI_SR_BANDS + TIRS_ST_BANDS)

with pytest.warns(UserWarning):
stats = landsat.statistics()
assert list(stats) == list(landsat.bands)

stats = landsat.statistics(bands="SR_B1")
assert stats["SR_B1"]["percentile_2"]
assert stats["SR_B1"]["percentile_98"]
assert stats["SR_B1"].percentile_2
assert stats["SR_B1"].percentile_98

stats = landsat.statistics(bands=landsat.bands)
assert len(stats.items()) == len(OLI_SR_BANDS + TIRS_ST_BANDS)
assert list(stats) == list(landsat.bands)

stats = landsat.statistics(bands="SR_B1", hist_options={"bins": 20})
assert len(stats["SR_B1"]["histogram"][0]) == 20
assert len(stats["SR_B1"].histogram[0]) == 20

stats = landsat.statistics(bands="QA_PIXEL")
assert stats["QA_PIXEL"]["min"] == 1
assert stats["QA_PIXEL"].min == 1

stats = landsat.statistics(
bands="QA_PIXEL", nodata=0, resampling_method="bilinear"
)
# nodata and resampling_method are set at reader level an shouldn't be set
assert stats["QA_PIXEL"]["min"] == 1
assert stats["QA_PIXEL"].min == 1

tile_z = 8
tile_x = 81
Expand Down
6 changes: 3 additions & 3 deletions tests/test_modis.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ def test_AWS_MODISPDSReader(rio):
)

metadata = modis.info(bands="B01")
assert metadata["band_descriptions"] == [("B01", "Nadir_Reflectance_Band1")]
assert metadata.band_descriptions == [("B01", "Nadir_Reflectance_Band1")]

with pytest.warns(UserWarning):
stats = modis.statistics()
assert list(stats) == list(modis.bands)

stats = modis.statistics(bands="B05")
assert len(stats.items()) == 1
assert stats["B05"]["percentile_2"]
assert stats["B05"]["percentile_98"]
assert stats["B05"].percentile_2
assert stats["B05"].percentile_98

tile_z = 7
tile_x = 76
Expand Down
6 changes: 3 additions & 3 deletions tests/test_modis_astraea.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ def test_AWS_MODISASTRAEAReader(rio):
)

metadata = modis.info(bands="B01")
assert metadata["band_descriptions"] == [("B01", "500m 16 days NDVI")]
assert metadata.band_descriptions == [("B01", "500m 16 days NDVI")]

with pytest.warns(UserWarning):
stats = modis.statistics()
assert list(stats) == list(modis.bands)

stats = modis.statistics(bands="B05")
assert len(stats.items()) == 1
assert stats["B05"]["percentile_2"]
assert stats["B05"]["percentile_98"]
assert stats["B05"].percentile_2
assert stats["B05"].percentile_98

tile_z = 8
tile_x = 219
Expand Down
10 changes: 5 additions & 5 deletions tests/test_sentinel1.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ def test_AWSPDS_S1L1CReader(rio, fetch):
sentinel.info(bands="B1")

metadata = sentinel.info(bands="vv")
assert len(metadata["band_metadata"]) == 1
assert metadata["band_metadata"][0][0] == "vv"
assert metadata["band_descriptions"] == [("vv", "")]
assert len(metadata.band_metadata) == 1
assert metadata.band_metadata[0][0] == "vv"
assert metadata.band_descriptions == [("vv", "")]

metadata = sentinel.statistics(bands=("vv", "vh"))
assert metadata["vv"]["min"] == 0
assert metadata["vh"]["max"] == 623
assert metadata["vv"].min == 0
assert metadata["vh"].max == 623

tile_z = 8
tile_x = 183
Expand Down
16 changes: 8 additions & 8 deletions tests/test_sentinel2.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def test_AWSPDS_S2L1CReader(rio, fetch):
assert values.data[0] == 1193.0 / 846.0

stats = sentinel.statistics(bands="B01")
assert stats["B01"]["percentile_2"]
assert stats["B01"]["percentile_98"]
assert stats["B01"].percentile_2
assert stats["B01"].percentile_98

tile_z = 8
tile_x = 78
Expand Down Expand Up @@ -233,8 +233,8 @@ def test_AWSPDS_S2L2AReader(rio, fetch):
assert sentinel._get_band_url("B1") == sentinel._get_band_url("B01")

stats = sentinel.statistics(bands="B01")
assert stats["B01"]["percentile_2"]
assert stats["B01"]["percentile_98"]
assert stats["B01"].percentile_2
assert stats["B01"].percentile_98

tile_z = 8
tile_x = 78
Expand Down Expand Up @@ -318,8 +318,8 @@ def test_AWSPDS_S2COGReader(rio, fetch):
assert sentinel._get_band_url("B1") == sentinel._get_band_url("B01")

stats = sentinel.statistics(bands="B01")
assert stats["B01"]["percentile_2"]
assert stats["B01"]["percentile_98"]
assert stats["B01"].percentile_2
assert stats["B01"].percentile_98

assert (
sentinel._get_band_url("B01")
Expand Down Expand Up @@ -352,8 +352,8 @@ def test_AWSPDS_S2COGReader(rio, fetch):
sentinel.statistics(bands="B25")

stats = sentinel.statistics(bands="B01")
assert stats["B01"]["percentile_2"]
assert stats["B01"]["percentile_98"]
assert stats["B01"].percentile_2
assert stats["B01"].percentile_98

assert (
sentinel._get_band_url("B01")
Expand Down

0 comments on commit 1b96e09

Please sign in to comment.