Skip to content

Commit

Permalink
fix: fix proximity computation test after param update
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaarnio committed Oct 18, 2024
1 parent 9419dfa commit 770ce79
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions tests/vector_processing/proximity_computation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@


@pytest.mark.parametrize(
"geodataframe,raster_profile,expected_shape,maximum_distance,scale,scaling_range",
"geodataframe,raster_profile,expected_shape,maximum_distance,scaling_range",
[
pytest.param(
gdf,
raster_profile,
EXPECTED_SMALL_RASTER_SHAPE,
25,
"linear",
(1, 0),
id="Inversion_and_scaling_between_1_and_0",
),
Expand All @@ -36,33 +35,31 @@
raster_profile,
EXPECTED_SMALL_RASTER_SHAPE,
25,
"linear",
(2, 1),
id="Inversion_and_scaling_between_2_and_1",
),
],
)
def test_proximity_computation_inversion_with_expected_result(
geodataframe, raster_profile, expected_shape, maximum_distance, scale, scaling_range
geodataframe, raster_profile, expected_shape, maximum_distance, scaling_range
):
"""Tests if the enteries in the output matrix are between the minimum and maximum value."""

result = proximity_computation(geodataframe, raster_profile, maximum_distance, scale, scaling_range)
result = proximity_computation(geodataframe, raster_profile, maximum_distance, scaling_range)

assert result.shape == expected_shape
# Assert that all values in result within scaling_range
assert np.all((result >= scaling_range[1]) & (result <= scaling_range[0])), "Scaling out of scaling_range"


@pytest.mark.parametrize(
"geodataframe,raster_profile,expected_shape,maximum_distance,scale,scaling_range",
"geodataframe,raster_profile,expected_shape,maximum_distance,scaling_range",
[
pytest.param(
gdf,
raster_profile,
EXPECTED_SMALL_RASTER_SHAPE,
25,
"linear",
(0, 1),
id="Scaling_between_0_and_1",
),
Expand All @@ -71,18 +68,17 @@ def test_proximity_computation_inversion_with_expected_result(
raster_profile,
EXPECTED_SMALL_RASTER_SHAPE,
25,
"linear",
(1, 2),
id="Scaling_between_1_and_2",
),
],
)
def test_proximity_computation_with_expected_result(
geodataframe, raster_profile, expected_shape, maximum_distance, scale, scaling_range
geodataframe, raster_profile, expected_shape, maximum_distance, scaling_range
):
"""Tests if the enteries in the output matrix are between the minimum and maximum value."""

result = proximity_computation(geodataframe, raster_profile, maximum_distance, scale, scaling_range)
result = proximity_computation(geodataframe, raster_profile, maximum_distance, scaling_range)

assert result.shape == expected_shape
# Assert that all values in result within scaling_range
Expand All @@ -93,5 +89,5 @@ def test_proximity_computation_with_expected_error():
"""Tests if an exception is raised for a negative maximum distance."""

with pytest.raises(NumericValueSignException, match="Expected max distance to be a positive number."):
result = proximity_computation(gdf, raster_profile, -25, "linear", (1, 0))
result = proximity_computation(gdf, raster_profile, -25, (1, 0))
assert np.all((result >= 0) & (result <= 1)), "Scaling out of scaling_range"

0 comments on commit 770ce79

Please sign in to comment.