From 2907c40ecce4a5d9e8e957da08fc636c2d6af804 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 07:59:58 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/metrics/test_mean_average_precision.py | 31 ++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/test/metrics/test_mean_average_precision.py b/test/metrics/test_mean_average_precision.py index b3b68249..bb0f91ef 100644 --- a/test/metrics/test_mean_average_precision.py +++ b/test/metrics/test_mean_average_precision.py @@ -1,8 +1,8 @@ """ Tests for Mean Average Precision ID=0 bug fix """ + import numpy as np -import pytest from supervision.detection.core import Detections from supervision.metrics.mean_average_precision import MeanAveragePrecision @@ -14,13 +14,13 @@ def test_single_perfect_detection(): detection = Detections( xyxy=np.array([[10, 10, 50, 50]], dtype=np.float64), class_id=np.array([0]), - confidence=np.array([0.9]) + confidence=np.array([0.9]), ) - + metric = MeanAveragePrecision() metric.update([detection], [detection]) result = metric.compute() - + # Should be perfect 1.0 mAP, not 0.0 due to ID=0 bug assert abs(result.map50_95 - 1.0) < 1e-6 @@ -29,19 +29,18 @@ def test_multiple_perfect_detections(): """Test that multiple perfect detections get 1.0 mAP""" # Multiple perfect detections in one image detections = Detections( - xyxy=np.array([ - [10, 10, 50, 50], - [100, 100, 140, 140], - [200, 200, 240, 240] - ], dtype=np.float64), + xyxy=np.array( + [[10, 10, 50, 50], [100, 100, 140, 140], [200, 200, 240, 240]], + dtype=np.float64, + ), class_id=np.array([0, 0, 0]), - confidence=np.array([0.9, 0.9, 0.9]) + confidence=np.array([0.9, 0.9, 0.9]), ) - + metric = MeanAveragePrecision() metric.update([detections], [detections]) result = metric.compute() - + # Should be perfect 1.0 mAP assert abs(result.map50_95 - 1.0) < 1e-6 @@ -52,15 +51,15 @@ def test_batch_updates_perfect_detections(): detection = Detections( xyxy=np.array([[10, 10, 50, 50]], dtype=np.float64), class_id=np.array([0]), - confidence=np.array([0.9]) + confidence=np.array([0.9]), ) - + metric = MeanAveragePrecision() # Add 3 batch updates metric.update([detection], [detection]) metric.update([detection], [detection]) metric.update([detection], [detection]) result = metric.compute() - + # Should be perfect 1.0 mAP across all batches - assert abs(result.map50_95 - 1.0) < 1e-6 \ No newline at end of file + assert abs(result.map50_95 - 1.0) < 1e-6