Skip to content

Commit 50fc7f4

Browse files
committed
added threshold validation tests
1 parent 8427b3f commit 50fc7f4

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/object_detection/test_evaluator.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ def test_evaluator_no_data(tmp_path: Path):
1717
Evaluator.load(tmp_path)
1818

1919

20+
def test_evaluator_valid_thresholds(tmp_path: Path):
21+
eval = Evaluator(
22+
path=tmp_path,
23+
detailed_cache=None, # type: ignore - testing
24+
ranked_cache=None, # type: ignore - testing
25+
info=None, # type: ignore - testing
26+
index_to_label={},
27+
number_of_groundtruths_per_label=np.ones(1, dtype=np.uint64),
28+
)
29+
for fn in [
30+
eval.compute_precision_recall,
31+
eval.compute_examples,
32+
eval.compute_confusion_matrix,
33+
eval.compute_confusion_matrix_with_examples,
34+
]:
35+
with pytest.raises(ValueError) as e:
36+
fn(iou_thresholds=[], score_thresholds=[0.5])
37+
assert "IOU" in str(e)
38+
with pytest.raises(ValueError) as e:
39+
fn(iou_thresholds=[0.5], score_thresholds=[])
40+
assert "score" in str(e)
41+
42+
2043
def test_metadata_using_torch_metrics_example(
2144
tmp_path: Path,
2245
torchmetrics_detections: list[Detection],

0 commit comments

Comments
 (0)