From c7a30ba06032d695bddf1e56ace1c97db92489bc Mon Sep 17 00:00:00 2001 From: Matic Lubej Date: Wed, 30 Aug 2023 12:07:20 +0200 Subject: [PATCH] update tests --- tests/geometry/test_morphology.py | 33 ++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/geometry/test_morphology.py b/tests/geometry/test_morphology.py index 0ca7076e..646e80ec 100644 --- a/tests/geometry/test_morphology.py +++ b/tests/geometry/test_morphology.py @@ -23,7 +23,10 @@ @pytest.fixture(name="patch") def patch_fixture() -> EOPatch: config = PatchGeneratorConfig(max_integer_value=10, raster_shape=(50, 100), depth_range=(3, 4)) - return generate_eopatch([MASK_FEATURE, MASK_TIMELESS_FEATURE], config=config) + patch = generate_eopatch([MASK_FEATURE, MASK_TIMELESS_FEATURE], config=config) + for feat in [MASK_FEATURE, MASK_TIMELESS_FEATURE]: + patch[feat] = patch[feat].astype(np.uint8) + return patch @pytest.mark.parametrize("invalid_input", [None, 0, "a"]) @@ -33,7 +36,7 @@ def test_erosion_value_error(invalid_input): def test_erosion_full(test_eopatch): - erosion_task = ErosionTask((FeatureType.MASK_TIMELESS, "LULC", "LULC_ERODED"), 1) + erosion_task = ErosionTask((FeatureType.MASK_TIMELESS, "LULC", "LULC_ERODED"), disk_radius=3) eopatch = erosion_task.execute(test_eopatch) mask_after = eopatch.mask_timeless["LULC_ERODED"] @@ -45,7 +48,7 @@ def test_erosion_partial(test_eopatch): # skip forest and artificial surface specific_labels = [0, 1, 3, 4] erosion_task = ErosionTask( - mask_feature=(FeatureType.MASK_TIMELESS, "LULC", "LULC_ERODED"), disk_radius=1, erode_labels=specific_labels + mask_feature=(FeatureType.MASK_TIMELESS, "LULC", "LULC_ERODED"), disk_radius=3, erode_labels=specific_labels ) eopatch = erosion_task.execute(test_eopatch) @@ -60,29 +63,23 @@ def test_erosion_partial(test_eopatch): ( MorphologicalOperations.DILATION, None, - [1, 30, 161, 669, 1690, 3557, 6973, 12247, 19462, 30210], - [7, 29, 112, 304, 639, 1336, 2465, 4012, 6096], - ), - (MorphologicalOperations.EROSION, MorphologicalStructFactory.get_disk(5), [74925, 72, 3], [14989, 11]), - (MorphologicalOperations.OPENING, MorphologicalStructFactory.get_disk(5), [73137, 1800, 63], [14720, 280]), - (MorphologicalOperations.CLOSING, MorphologicalStructFactory.get_disk(5), [1157, 73843], [501, 14499]), - ( - MorphologicalOperations.MEDIAN, - MorphologicalStructFactory.get_rectangle(5, 6), - [16, 562, 6907, 24516, 28864, 12690, 1403, 42], - [71, 1280, 4733, 5924, 2592, 382, 18], + [6, 34, 172, 768, 2491, 7405, 19212, 44912], + [1, 2, 16, 104, 466, 1490, 3870, 9051], ), + (MorphologicalOperations.EROSION, MorphologicalStructFactory.get_disk(11), [74957, 42, 1], [14994, 6]), + (MorphologicalOperations.OPENING, MorphologicalStructFactory.get_disk(11), [73899, 1051, 50], [14837, 163]), + (MorphologicalOperations.CLOSING, MorphologicalStructFactory.get_disk(11), [770, 74230], [425, 14575]), ( MorphologicalOperations.OPENING, MorphologicalStructFactory.get_rectangle(5, 6), - [47486, 24132, 2565, 497, 169, 96, 35, 20], - [9929, 4446, 494, 53, 54, 16, 8], + [48468, 24223, 2125, 169, 15], + [10146, 4425, 417, 3, 9], ), ( MorphologicalOperations.DILATION, MorphologicalStructFactory.get_rectangle(5, 6), - [2, 20, 184, 3888, 70906], - [3, 32, 748, 14217], + [2, 19, 198, 3929, 70852], + [32, 743, 14225], ), ], )