Skip to content

Commit

Permalink
Merge origin
Browse files Browse the repository at this point in the history
  • Loading branch information
Draga Doncila committed Dec 4, 2023
2 parents 1c990ee + 4d0b5b3 commit 023778e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
2 changes: 2 additions & 0 deletions tests/loaders/test_ctc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_ctc_single_nodes():
# This should raise an error if there are no times for single nodes
TrackingGraph(G)


def test_ctc_with_gap_closing():
data = [
{"Cell_ID": 1, "Start": 0, "End": 1, "Parent_ID": 0},
Expand All @@ -81,6 +82,7 @@ def test_ctc_with_gap_closing():
assert G.has_edge("1_1", "3_3")
assert G.has_edge("2_1", "4_6")


def test_load_data():
test_dir = os.path.abspath(__file__)
data_dir = os.path.abspath(
Expand Down
28 changes: 23 additions & 5 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def get_division_graphs():
def get_gap_close_graphs():
"""
G1
3_5 -- 3_6 -- -- -- 5_10
3_5 -- 3_6 -- -- -- 5_10
1_0 -- 1_1 -- -- -- 2_3 -- 2_4 -<
4_5 -- 4_6
G2
2_5 -- 2_6 -- -- -- 4_10
2_5 -- 2_6 -- -- -- 4_10
1_0 -- 1_1 -- 1_2 -- 1_3 -- 1_4 -<
3_5 -- 3_6
"""
Expand Down Expand Up @@ -201,10 +201,21 @@ def get_gap_close_graphs():
nx.set_node_attributes(G2, attrs)

# G1, G2 mapper
mapper = [("1_0", "1_0"), ("1_1", "1_1"), ("2_3", "1_3"), ("2_4", "1_4"), ("3_5", "2_5"), ("3_6", "2_6"), ("5_10", "4_10"), ("4_5", "3_5"), ("4_6", "3_6")]
mapper = [
("1_0", "1_0"),
("1_1", "1_1"),
("2_3", "1_3"),
("2_4", "1_4"),
("3_5", "2_5"),
("3_6", "2_6"),
("5_10", "4_10"),
("4_5", "3_5"),
("4_6", "3_6"),
]

return G1, G2, mapper


def get_division_gap_close_graphs():
"""
G1
Expand Down Expand Up @@ -248,6 +259,13 @@ def get_division_gap_close_graphs():
attrs[node] = {"t": int(node[-1:]), "x": 0, "y": 0}
nx.set_node_attributes(G2, attrs)

mapper = [("1_0", "1_0"), ("1_1", "1_1"), ("2_3", "2_3"), ("2_4", "2_4"), ("3_2", "3_2"), ("3_4", "4_4")]
mapper = [
("1_0", "1_0"),
("1_1", "1_1"),
("2_3", "2_3"),
("2_4", "2_4"),
("3_2", "3_2"),
("3_4", "4_4"),
]

return G1, G2, mapper
return G1, G2, mapper
21 changes: 11 additions & 10 deletions tests/track_errors/test_divisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
_get_succ_by_t,
)

from tests.test_utils import get_division_graphs, get_division_gap_close_graphs
from tests.test_utils import get_division_gap_close_graphs, get_division_graphs


@pytest.fixture
Expand Down Expand Up @@ -221,28 +221,29 @@ def test_evaluate_division_events():

assert np.all([isinstance(k, int) for k in results.keys()])


def test_gap_close_divisions():
g_gt, g_pred, mapper = get_division_gap_close_graphs()
matched_data = Matched(TrackingGraph(g_gt), TrackingGraph(g_pred), mapper)
_classify_divisions(matched_data)

# missing gap close div edge so FN DIV
assert g_gt.nodes['1_1'][NodeAttr.FN_DIV]
assert g_gt.nodes["1_1"][NodeAttr.FN_DIV]

# fix division, assert it's identified correctly
g_pred.remove_node('2_2')
g_pred.add_edge('1_1', '2_3')
g_pred.remove_node("2_2")
g_pred.add_edge("1_1", "2_3")
# mapper doesn't need to change as removed node was always missing
matched_data = Matched(TrackingGraph(g_gt), TrackingGraph(g_pred), mapper)
_classify_divisions(matched_data)
assert g_gt.nodes['1_1'][NodeAttr.TP_DIV]
assert g_gt.nodes['1_1'][NodeAttr.TP_DIV]
assert g_gt.nodes["1_1"][NodeAttr.TP_DIV]
assert g_gt.nodes["1_1"][NodeAttr.TP_DIV]

g_gt, g_pred, mapper = get_division_gap_close_graphs()
# remove gt division
g_gt.remove_edge('1_1', '2_3')
g_gt.remove_edge('1_1', '3_2')
g_gt.remove_edge("1_1", "2_3")
g_gt.remove_edge("1_1", "3_2")
matched_data = Matched(TrackingGraph(g_gt), TrackingGraph(g_pred), mapper)
_classify_divisions(matched_data)
# assert fp division classified correctly
assert g_pred.nodes['1_1'][NodeAttr.FP_DIV]
assert g_pred.nodes["1_1"][NodeAttr.FP_DIV]

1 comment on commit 023778e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark Mean (s) BASE ef50a44 Mean (s) HEAD 023778e Percent Change
test_load_gt_data 1.39667 1.26748 -9.25
test_load_pred_data 1.16082 1.15 -0.93
test_ctc_matched 2.24662 2.25495 0.37
test_ctc_metrics 0.5703 0.54075 -5.18
test_ctc_div_metrics 0.28662 0.27132 -5.34
test_iou_matched 9.56684 9.43597 -1.37
test_iou_div_metrics 0.27151 0.27039 -0.41

Please sign in to comment.