Skip to content

Commit 8a8e4ad

Browse files
author
Matic Lubej
committed
add test for empty eopatch
1 parent 9db5efe commit 8a8e4ad

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/mask/test_snow_mask.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
import pytest
1212

13-
from eolearn.core import FeatureType
13+
from eolearn.core import FeatureType, EOPatch
1414
from eolearn.mask import SnowMaskTask
1515

1616

@@ -33,3 +33,12 @@ def test_snow_coverage(task, result, test_eopatch):
3333
snow_pixels = np.sum(output, axis=(1, 2, 3))
3434
assert np.sum(snow_pixels) == result[0], "Sum of snowy pixels does not match"
3535
assert snow_pixels[-4] == result[1], "Snowy pixels on specified frame do not match"
36+
37+
38+
def test_snow_empty_eopatch(test_eopatch):
39+
bands = test_eopatch.data["BANDS-S2-L1C"]
40+
empty_bands_array = np.array([], dtype=bands.dtype).reshape((0, *bands.shape[1:]))
41+
empty_eopatch = EOPatch(bbox=test_eopatch.bbox, timestamps=[], data={"BANDS-S2-L1C": empty_bands_array})
42+
task = SnowMaskTask((FeatureType.DATA, "BANDS-S2-L1C"), [2, 3, 7, 11], mask_name="TEST_SNOW_MASK")
43+
resulting_eopatch = task(empty_eopatch) # checks if the task runs without errors
44+
assert resulting_eopatch.mask["TEST_SNOW_MASK"].shape[0] == 0

0 commit comments

Comments
 (0)