Skip to content

Commit

Permalink
Add test for empty predictions
Browse files Browse the repository at this point in the history
Reproduces issue: cheind#49
  • Loading branch information
Jack Valmadre committed Nov 30, 2019
1 parent 3dc9ea1 commit 184f609
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions motmetrics/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,45 @@ def compute_motchallenge(dname):
[0.624296, 0.799176, 0.512211, 0.602640, 0.940268, 18.0, 6, 10, 2, 58, 602, 14, 13, 0.555116, 0.330177],
])
np.testing.assert_allclose(summary, expected, atol=1e-3)


def test_optimal_assignment_metrics_with_empty_groundtruth():
acc = mm.MOTAccumulator(auto_id=True)
# Empty groundtruth.
acc.update([], [1, 2, 3, 4], [])
acc.update([], [1, 2, 3, 4], [])
acc.update([], [1, 2, 3, 4], [])
acc.update([], [1, 2, 3, 4], [])

mh = mm.metrics.create()
metr = mh.compute(acc, return_dataframe=False, metrics=[
'num_matches', 'num_false_positives', 'num_misses',
'idtp', 'idfp', 'idfn',
])
assert metr['num_matches'] == 0
assert metr['num_false_positives'] == 16
assert metr['num_misses'] == 0
assert metr['idtp'] == 0
assert metr['idfp'] == 16
assert metr['idfn'] == 0


def test_optimal_assignment_metrics_with_empty_predictions():
acc = mm.MOTAccumulator(auto_id=True)
# Empty predictions.
acc.update([1, 2, 3, 4], [], [])
acc.update([1, 2, 3, 4], [], [])
acc.update([1, 2, 3, 4], [], [])
acc.update([1, 2, 3, 4], [], [])

mh = mm.metrics.create()
metr = mh.compute(acc, return_dataframe=False, metrics=[
'num_matches', 'num_false_positives', 'num_misses',
'idtp', 'idfp', 'idfn',
])
assert metr['num_matches'] == 0
assert metr['num_false_positives'] == 0
assert metr['num_misses'] == 16
assert metr['idtp'] == 0
assert metr['idfp'] == 0
assert metr['idfn'] == 16

0 comments on commit 184f609

Please sign in to comment.