Skip to content

Commit 8791b0c

Browse files
committed
Add test of split_labeled_regions
1 parent b41dbd1 commit 8791b0c

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

proseco/tests/test_acq.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
get_image_props,
2424
get_imposter_stars,
2525
get_p_man_err,
26+
split_labeled_regions,
2627
)
2728
from ..catalog import get_aca_catalog
2829
from ..core import ACABox, StarsTable
@@ -1375,3 +1376,65 @@ def test_acq_include_ids_all_halfws_full_catalog_with_spoiler():
13751376
assert np.all(aca.acqs["id"] == ids)
13761377
assert np.allclose(aca.acqs["mag"], mags)
13771378
assert np.all(aca.acqs["halfw"] == halfws)
1379+
1380+
1381+
img_input = np.array(
1382+
[
1383+
[4, 4, 0, 1, 1, 0],
1384+
[0, 0, 0, 1, 1, 0],
1385+
[1, 1, 1, 1, 1, 0],
1386+
[0, 2, 2, 3, 1, 0],
1387+
[0, 2, 2, 0, 1, 0],
1388+
[0, 0, 0, 0, 0, 0],
1389+
]
1390+
)
1391+
1392+
test_split_labeled_regions_cases = [
1393+
{
1394+
"img_exp": [
1395+
[4, 4, 0, 1, 1, 0],
1396+
[0, 0, 0, 1, 1, 0],
1397+
[1, 1, 1, 1, 1, 0],
1398+
[0, 2, 2, 3, 1, 0],
1399+
[0, 2, 2, 0, 1, 0],
1400+
[0, 0, 0, 0, 0, 0],
1401+
],
1402+
"max_size": 5,
1403+
"n_region": 4,
1404+
},
1405+
{
1406+
"img_exp": [
1407+
[6, 6, 0, 1, 2, 0],
1408+
[0, 0, 0, 1, 2, 0],
1409+
[1, 1, 1, 1, 2, 0],
1410+
[0, 4, 4, 5, 2, 0],
1411+
[0, 4, 4, 0, 3, 0],
1412+
[0, 0, 0, 0, 0, 0],
1413+
],
1414+
"max_size": 4,
1415+
"n_region": 6,
1416+
},
1417+
{
1418+
"img_exp": [
1419+
[9, 9, 0, 1, 2, 0],
1420+
[0, 0, 0, 1, 2, 0],
1421+
[3, 3, 4, 4, 5, 0],
1422+
[0, 7, 7, 8, 5, 0],
1423+
[0, 7, 7, 0, 6, 0],
1424+
[0, 0, 0, 0, 0, 0],
1425+
],
1426+
"max_size": 2,
1427+
"n_region": 9,
1428+
},
1429+
]
1430+
1431+
1432+
@pytest.mark.parametrize("test_case", test_split_labeled_regions_cases)
1433+
def test_split_labeled_regions(test_case):
1434+
img_exp = test_case["img_exp"]
1435+
max_size = test_case["max_size"]
1436+
n_region = test_case["n_region"]
1437+
1438+
img_split, n_regions = split_labeled_regions(img_input, max_size=max_size)
1439+
assert n_regions == n_region
1440+
assert np.all(img_split == img_exp)

0 commit comments

Comments
 (0)