diff --git a/src/motile_toolbox/candidate_graph/graph_attributes.py b/src/motile_toolbox/candidate_graph/graph_attributes.py index 478c2b3..a2927e7 100644 --- a/src/motile_toolbox/candidate_graph/graph_attributes.py +++ b/src/motile_toolbox/candidate_graph/graph_attributes.py @@ -19,5 +19,4 @@ class EdgeAttr(Enum): implementations of commonly used ones, listed here. """ - DISTANCE = "distance" IOU = "iou" diff --git a/tests/conftest.py b/tests/conftest.py index 93bbd17..ae62bd1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -90,8 +90,8 @@ def graph_2d(): ), ] edges = [ - ("0_1", "1_1", {EdgeAttr.DISTANCE.value: 42.43, EdgeAttr.IOU.value: 0.0}), - ("0_1", "1_2", {EdgeAttr.DISTANCE.value: 11.18, EdgeAttr.IOU.value: 0.395}), + ("0_1", "1_1", {EdgeAttr.IOU.value: 0.0}), + ("0_1", "1_2", {EdgeAttr.IOU.value: 0.395}), ] graph.add_nodes_from(nodes) graph.add_edges_from(edges) @@ -159,25 +159,25 @@ def multi_hypothesis_graph_2d(): ] edges = [ - ("0_0_1", "1_0_1", {EdgeAttr.DISTANCE.value: 42.426, EdgeAttr.IOU.value: 0.0}), - ("0_0_1", "1_1_1", {EdgeAttr.DISTANCE.value: 43.011, EdgeAttr.IOU.value: 0.0}), + ("0_0_1", "1_0_1", {EdgeAttr.IOU.value: 0.0}), + ("0_0_1", "1_1_1", {EdgeAttr.IOU.value: 0.0}), ( "0_0_1", "1_0_2", - {EdgeAttr.DISTANCE.value: 11.180, EdgeAttr.IOU.value: 0.3931}, + {EdgeAttr.IOU.value: 0.3931}, ), ( "0_0_1", "1_1_2", - {EdgeAttr.DISTANCE.value: 11.180, EdgeAttr.IOU.value: 0.4768}, + {EdgeAttr.IOU.value: 0.4768}, ), - ("0_1_1", "1_0_1", {EdgeAttr.DISTANCE.value: 43.011, EdgeAttr.IOU.value: 0.0}), - ("0_1_1", "1_1_1", {EdgeAttr.DISTANCE.value: 42.426, EdgeAttr.IOU.value: 0.0}), - ("0_1_1", "1_0_2", {EdgeAttr.DISTANCE.value: 15.0, EdgeAttr.IOU.value: 0.2402}), + ("0_1_1", "1_0_1", {EdgeAttr.IOU.value: 0.0}), + ("0_1_1", "1_1_1", {EdgeAttr.IOU.value: 0.0}), + ("0_1_1", "1_0_2", {EdgeAttr.IOU.value: 0.2402}), ( "0_1_1", "1_1_2", - {EdgeAttr.DISTANCE.value: 11.180, EdgeAttr.IOU.value: 0.3931}, + {EdgeAttr.IOU.value: 0.3931}, ), ] graph.add_nodes_from(nodes) @@ -276,9 +276,9 @@ def graph_3d(): ] edges = [ # math.dist([50, 50], [20, 80]) - ("0_1", "1_1", {EdgeAttr.DISTANCE.value: 42.43}), + ("0_1", "1_1"), # math.dist([50, 50], [60, 45]) - ("0_1", "1_2", {EdgeAttr.DISTANCE.value: 11.18}), + ("0_1", "1_2"), ] graph.add_nodes_from(nodes) graph.add_edges_from(edges) @@ -336,12 +336,12 @@ def multi_hypothesis_graph_3d(): ), ] edges = [ - ("0_0_1", "1_0_1", {EdgeAttr.DISTANCE.value: 42.4264}), - ("0_0_1", "1_0_2", {EdgeAttr.DISTANCE.value: 11.1803}), - ("0_1_1", "1_0_1", {EdgeAttr.DISTANCE.value: 35.3553}), - ("0_1_1", "1_0_2", {EdgeAttr.DISTANCE.value: 18.0277}), - ("0_0_1", "1_1_1", {EdgeAttr.DISTANCE.value: 40.3112}), - ("0_1_1", "1_1_1", {EdgeAttr.DISTANCE.value: 33.5410}), + ("0_0_1", "1_0_1"), + ("0_0_1", "1_0_2"), + ("0_1_1", "1_0_1"), + ("0_1_1", "1_0_2"), + ("0_0_1", "1_1_1"), + ("0_1_1", "1_1_1"), ] graph.add_nodes_from(nodes) graph.add_edges_from(edges) diff --git a/tests/test_candidate_graph/test_compute_graph.py b/tests/test_candidate_graph/test_compute_graph.py index eaeb241..77ce13d 100644 --- a/tests/test_candidate_graph/test_compute_graph.py +++ b/tests/test_candidate_graph/test_compute_graph.py @@ -17,10 +17,6 @@ def test_graph_from_segmentation_2d(segmentation_2d, graph_2d): assert Counter(cand_graph.nodes[node]) == Counter(graph_2d.nodes[node]) for edge in cand_graph.edges: print(cand_graph.edges[edge]) - assert ( - pytest.approx(cand_graph.edges[edge][EdgeAttr.DISTANCE.value], abs=0.01) - == graph_2d.edges[edge][EdgeAttr.DISTANCE.value] - ) assert ( pytest.approx(cand_graph.edges[edge][EdgeAttr.IOU.value], abs=0.01) == graph_2d.edges[edge][EdgeAttr.IOU.value] @@ -33,9 +29,6 @@ def test_graph_from_segmentation_2d(segmentation_2d, graph_2d): ) assert Counter(list(cand_graph.nodes)) == Counter(["0_1", "1_1", "1_2"]) assert Counter(list(cand_graph.edges)) == Counter([("0_1", "1_2")]) - assert cand_graph.edges[("0_1", "1_2")][EdgeAttr.DISTANCE.value] == pytest.approx( - 11.18, abs=0.01 - ) def test_graph_from_segmentation_3d(segmentation_3d, graph_3d): @@ -72,10 +65,6 @@ def test_graph_from_multi_segmentation_2d( multi_hypothesis_graph_2d.nodes[node] ) for edge in cand_graph.edges: - assert ( - pytest.approx(cand_graph.edges[edge][EdgeAttr.DISTANCE.value], abs=0.01) - == multi_hypothesis_graph_2d.edges[edge][EdgeAttr.DISTANCE.value] - ) assert ( pytest.approx(cand_graph.edges[edge][EdgeAttr.IOU.value], abs=0.01) == multi_hypothesis_graph_2d.edges[edge][EdgeAttr.IOU.value] diff --git a/tests/test_candidate_graph/test_utils.py b/tests/test_candidate_graph/test_utils.py index afa9ea1..9b4dda6 100644 --- a/tests/test_candidate_graph/test_utils.py +++ b/tests/test_candidate_graph/test_utils.py @@ -75,11 +75,6 @@ def test_add_cand_edges_2d(graph_2d): cand_graph = nx.create_empty_copy(graph_2d) add_cand_edges(cand_graph, max_edge_distance=50) assert Counter(list(cand_graph.edges)) == Counter(list(graph_2d.edges)) - for edge in cand_graph.edges: - assert ( - pytest.approx(cand_graph.edges[edge][EdgeAttr.DISTANCE.value], abs=0.01) - == graph_2d.edges[edge][EdgeAttr.DISTANCE.value] - ) def test_add_cand_edges_3d(graph_3d): @@ -87,8 +82,6 @@ def test_add_cand_edges_3d(graph_3d): add_cand_edges(cand_graph, max_edge_distance=15) graph_3d.remove_edge("0_1", "1_1") assert Counter(list(cand_graph.edges)) == Counter(list(graph_3d.edges)) - for edge in cand_graph.edges: - assert pytest.approx(cand_graph.edges[edge], abs=0.01) == graph_3d.edges[edge] def test_get_node_id():