Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
matrix:
os: [ubuntu-latest]
dev: [false]
python: ["3.10", "3.11", "3.12"]
python: ["3.10", "3.11", "3.12", "3.13"]
env: ["latest"]
# Use openblas instead of mkl saves 600 MB. Linux OK, 50% slower on Windows and OSX!
extra: ["nomkl"]
Expand All @@ -44,7 +44,7 @@ jobs:
- env: latest
os: windows-latest
dev: false
python: "3.12"
python: "3.13"

steps:
- uses: actions/checkout@v6
Expand Down
150 changes: 142 additions & 8 deletions tests/test_raster_index_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,38 @@ def test_calc_index_invalid(tmp_path):
"index, pixel_type, process_options, expected_bands",
[
("dprvi", "BYTE", {}, ["dprvi"]),
("dprvi", "FLOAT16", None, ["dprvi"]),
pytest.param(
"dprvi",
"FLOAT16",
None,
["dprvi"],
marks=pytest.mark.skipif(
rasterio.__version__ == "1.4.4",
reason="Requires rasterio <> 1.4.4",
),
),
("dprvi", "FLOAT32", {}, ["dprvi"]),
("rvi", "BYTE", {}, ["rvi"]),
("vvdvh", "FLOAT16", {}, ["vvdvh"]),
("sarrgb", "FLOAT16", {}, ["vv", "vh", "vvdvh"]),
pytest.param(
"vvdvh",
"FLOAT16",
{},
["vvdvh"],
marks=pytest.mark.skipif(
rasterio.__version__ == "1.4.4",
reason="Requires rasterio <> 1.4.4",
),
),
pytest.param(
"sarrgb",
"FLOAT16",
{},
["vv", "vh", "vvdvh"],
marks=pytest.mark.skipif(
rasterio.__version__ == "1.4.4",
reason="Requires rasterio <> 1.4.4",
),
),
("sarrgb", "FLOAT32", {"log10": True}, ["vvdb", "vhdb", "vvdvhdb"]),
("sarrgb", "BYTE", {"log10": True}, ["vvdb", "vhdb", "vvdvhdb"]),
(
Expand Down Expand Up @@ -211,7 +238,26 @@ def test_calc_index_s1_error(


@pytest.mark.parametrize(
"index, pixel_type", [("ndvi", "BYTE"), ("ndvi", "FLOAT16"), ("bsi", "FLOAT16")]
"index, pixel_type",
[
("ndvi", "BYTE"),
pytest.param(
"ndvi",
"FLOAT16",
marks=pytest.mark.skipif(
rasterio.__version__ == "1.4.4",
reason="Requires rasterio <> 1.4.4",
),
),
pytest.param(
"bsi",
"FLOAT16",
marks=pytest.mark.skipif(
rasterio.__version__ == "1.4.4",
reason="Requires rasterio <> 1.4.4",
),
),
],
)
def test_calc_index_s2(tmp_path, index, pixel_type):
# Prepare test data
Expand All @@ -236,20 +282,108 @@ def test_calc_index_s2(tmp_path, index, pixel_type):
[
("ndvi", "BYTE", gdal.GDT_UInt16, 32676, ["B04", "B08", "b1"], "uint8", 255),
("ndvi", "BYTE", gdal.GDT_Float32, np.nan, ["B04", "B08"], "uint8", 255),
("ndvi", "FLOAT16", gdal.GDT_UInt16, 32676, ["B04", "B08"], "float32", np.nan),
(
pytest.param(
"ndvi",
"FLOAT16",
gdal.GDT_UInt16,
32676,
["B04", "B08"],
"float16",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ < "1.5", reason="Requires rasterio 1.5 or higher"
),
),
pytest.param(
"ndvi",
"FLOAT16",
gdal.GDT_Float32,
np.nan,
["B04", "B08"],
"float16",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ < "1.5", reason="Requires rasterio 1.5 or higher"
),
),
pytest.param(
"ndvi",
"FLOAT16",
gdal.GDT_UInt16,
32676,
["B04", "B08"],
"float32",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ >= "1.5" or rasterio.__version__ == "1.4.4",
reason="Requires rasterio < 1.5",
),
),
pytest.param(
"ndvi",
"FLOAT16",
gdal.GDT_Float32,
np.nan,
["B04", "B08"],
"float32",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ >= "1.5" or rasterio.__version__ == "1.4.4",
reason="Requires rasterio < 1.5",
),
),
("dprvi", "BYTE", gdal.GDT_UInt16, 32676, ["VH", "VV"], "uint8", 255),
("dprvi", "BYTE", gdal.GDT_Float32, np.nan, ["VH", "VV"], "uint8", 255),
("dprvi", "FLOAT16", gdal.GDT_UInt16, 32676, ["VH", "VV"], "float32", np.nan),
("dprvi", "FLOAT16", gdal.GDT_Float32, np.nan, ["VH", "VV"], "float32", np.nan),
pytest.param(
"dprvi",
"FLOAT16",
gdal.GDT_UInt16,
32676,
["VH", "VV"],
"float16",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ < "1.5", reason="Requires rasterio 1.5 or higher"
),
),
pytest.param(
"dprvi",
"FLOAT16",
gdal.GDT_Float32,
np.nan,
["VH", "VV"],
"float16",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ < "1.5", reason="Requires rasterio 1.5 or higher"
),
),
pytest.param(
"dprvi",
"FLOAT16",
gdal.GDT_UInt16,
32676,
["VH", "VV"],
"float32",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ >= "1.5" or rasterio.__version__ == "1.4.4",
reason="Requires rasterio < 1.5",
),
),
pytest.param(
"dprvi",
"FLOAT16",
gdal.GDT_Float32,
np.nan,
["VH", "VV"],
"float32",
np.nan,
marks=pytest.mark.skipif(
rasterio.__version__ >= "1.5" or rasterio.__version__ == "1.4.4",
reason="Requires rasterio < 1.5",
),
),
],
)
def test_calc_index_by_gdal_raster(
Expand Down
Loading