Skip to content

Commit

Permalink
Merge pull request #1046 from AFM-SPM/ns-rse/enhance-bbox-test
Browse files Browse the repository at this point in the history
tests(unet_masking): Correct ids and add expected fail
  • Loading branch information
MaxGamill-Sheffield authored Dec 11, 2024
2 parents 5b2f473 + af613a5 commit 0625a55
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions tests/test_unet_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,29 @@ def test_predict_unet(mock_model_5_by_5_single_class: MagicMock) -> None:
("crop_min_row", "crop_min_col", "crop_max_row", "crop_max_col", "image_shape", "expected_indices"),
[
pytest.param(0, 0, 100, 100, (100, 100), (0, 0, 100, 100), id="not a crop"),
pytest.param(3, 4, 8, 8, (10, 10), (3, 4, 8, 9), id="free space single min col decrease"),
pytest.param(4, 3, 8, 8, (10, 10), (4, 3, 9, 8), id="free space single min row decrease"),
pytest.param(4, 4, 7, 8, (10, 10), (4, 4, 8, 8), id="free space single max col increase"),
pytest.param(4, 4, 8, 7, (10, 10), (4, 4, 8, 8), id="free space single max row increase"),
pytest.param(4, 2, 8, 8, (10, 10), (3, 2, 9, 8), id="free space double min col decrease"),
pytest.param(2, 4, 8, 8, (10, 10), (2, 3, 8, 9), id="free space double min row decrease"),
pytest.param(4, 4, 8, 6, (10, 10), (4, 3, 8, 7), id="free space double max col increase"),
pytest.param(4, 4, 6, 8, (10, 10), (3, 4, 7, 8), id="free space double max row increase"),
pytest.param(3, 4, 8, 8, (10, 10), (3, 4, 8, 9), id="free space single max col increase"),
pytest.param(4, 3, 8, 8, (10, 10), (4, 3, 9, 8), id="free space single max row increase"),
pytest.param(4, 4, 7, 8, (10, 10), (4, 4, 8, 8), id="free space single max row increase"),
pytest.param(4, 4, 8, 7, (10, 10), (4, 4, 8, 8), id="free space single max col increase"),
pytest.param(4, 2, 8, 8, (10, 10), (3, 2, 9, 8), id="free space double min row decrease, max row increase"),
pytest.param(2, 4, 8, 8, (10, 10), (2, 3, 8, 9), id="free space double min col decrease, max col increase"),
pytest.param(4, 4, 8, 6, (10, 10), (4, 3, 8, 7), id="free space double min col decrease, max col increase"),
pytest.param(4, 4, 6, 8, (10, 10), (3, 4, 7, 8), id="free space double min row decrease, max row increase"),
pytest.param(1, 1, 6, 2, (10, 10), (1, 0, 6, 5), id="constrained left"),
pytest.param(1, 6, 7, 8, (10, 10), (1, 3, 7, 9), id="constrained right"),
pytest.param(1, 1, 2, 6, (10, 10), (0, 1, 5, 6), id="constrained top"),
pytest.param(6, 1, 8, 7, (10, 10), (3, 1, 9, 7), id="constrained bottom"),
pytest.param(117, 20, 521, 603, (608, 608), (24, 20, 607, 603), id="constrained top and bottom"),
pytest.param(
1,
1,
2,
4,
(2, 4),
(0, 1, 2, 4),
id="rectangular image with large rectangular box",
marks=pytest.mark.xfail(reason="square bounding box not possible"),
),
],
)
def test_make_bounding_box_square(
Expand All @@ -174,7 +184,7 @@ def test_make_bounding_box_square(
image_shape: tuple[int, int],
expected_indices: tuple[int, int, int, int],
) -> None:
"""Test the make_bounding_box_square method."""
"""Test the make_bounding_box_square method returns square objects within image shape with known coordinates."""
result = make_bounding_box_square(crop_min_row, crop_min_col, crop_max_row, crop_max_col, image_shape)
# check bbox within image bounds
assert result[0] >= 0
Expand Down

0 comments on commit 0625a55

Please sign in to comment.