Skip to content

Commit 89dbe32

Browse files
authored
Warning added in motmetrics.utils.compare_to_groundtruth() to mitigate backward compatibility issues. (#177)
When the dist='euc' option is used, a warning is shown to explain the change in behavior of the option.
1 parent 22483cb commit 89dbe32

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

motmetrics/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_annotations_xor_predictions_present():
3131
}
3232
anno = _tracks_to_dataframe(anno_tracks)
3333
pred = _tracks_to_dataframe(pred_tracks)
34-
acc = mm.utils.compare_to_groundtruth(anno, pred, 'euc', distfields=['Position'], distth=2)
34+
acc = mm.utils.compare_to_groundtruth(anno, pred, 'euclidean', distfields=['Position'], distth=2)
3535
mh = mm.metrics.create()
3636
metrics = mh.compute(acc, return_dataframe=False, metrics=[
3737
'num_objects', 'num_predictions', 'num_unique_objects',

motmetrics/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def compare_to_groundtruth(gt, dt, dist='iou', distfields=None, distth=0.5):
3838
------
3939
dist : str, optional
4040
String identifying distance to be used. Defaults to intersection over union ('iou'). Euclidean
41-
distance ('euc') and squared euclidean distance ('seuc') are also supported.
41+
distance ('euclidean') and squared euclidean distance ('seuc') are also supported.
4242
distfields: array, optional
4343
Fields relevant for extracting distance information. Defaults to ['X', 'Y', 'Width', 'Height']
4444
distth: float, optional
@@ -61,10 +61,14 @@ def compute_seuc(a, b):
6161
compute_dist = compute_iou
6262
elif dist.upper() == 'EUC':
6363
compute_dist = compute_euc
64+
import warnings
65+
warnings.warn(f"'euc' flag changed its behavior. The euclidean distance is now used instead of the squared euclidean distance. Make sure the used threshold (distth={distth}) is not squared. Use 'euclidean' flag to avoid this warning.")
66+
elif dist.upper() == 'EUCLIDEAN':
67+
compute_dist = compute_euc
6468
elif dist.upper() == 'SEUC':
6569
compute_dist = compute_seuc
6670
else:
67-
raise f'Unknown distance metric {dist}. Use "IOU", "EUC" or "SEUC"'
71+
raise f'Unknown distance metric {dist}. Use "IOU", "EUCLIDEAN", or "SEUC"'
6872

6973
acc = MOTAccumulator()
7074

0 commit comments

Comments
 (0)