Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matic Lubej committed Aug 30, 2023
1 parent 7b9d82a commit c7a30ba
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions tests/geometry/test_morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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"]
Expand All @@ -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)

Expand All @@ -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],
),
],
)
Expand Down

0 comments on commit c7a30ba

Please sign in to comment.