{"record":{"id":"a7023ec2be9b335d","repo":"roboflow/supervision","slug":"invalid-metric-target-self-metric-target-a7023e","errorCode":null,"errorMessage":"Invalid metric target: {self._metric_target}","messagePattern":"Invalid metric target: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/precision.py","lineNumber":533,"sourceCode":"        \"\"\"Return boxes, masks or oriented bounding boxes from detections.\"\"\"\n        if self._metric_target == MetricTarget.BOXES:\n            return cast(npt.NDArray[Any], detections.xyxy)\n        if self._metric_target == MetricTarget.MASKS:\n            if detections.mask is not None:\n                return cast(npt.NDArray[Any], detections.mask)\n            if len(detections) > 0:\n                raise ValueError(\n                    \"Precision with `MetricTarget.MASKS` requires detections to \"\n                    \"include masks.\"\n                )\n            return self._make_empty_content()\n        if self._metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:\n            obb = detections.data.get(ORIENTED_BOX_COORDINATES)\n            if obb is not None and len(obb) > 0:\n                result_obb: npt.NDArray[np.float32] = np.array(obb, dtype=np.float32)\n                return result_obb\n            return self._make_empty_content()\n        raise ValueError(f\"Invalid metric target: {self._metric_target}\")\n\n    def _make_empty_content(self) -> npt.NDArray[Any]:\n        if self._metric_target == MetricTarget.BOXES:\n            empty_boxes: npt.NDArray[np.float32] = np.empty((0, 4), dtype=np.float32)\n            return empty_boxes\n\n        if self._metric_target == MetricTarget.MASKS:\n            empty_masks: npt.NDArray[np.bool_] = np.empty((0, 0, 0), dtype=bool)\n            return empty_masks\n\n        if self._metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:\n            empty_obb: npt.NDArray[np.float32] = np.empty((0, 4, 2), dtype=np.float32)\n            return empty_obb\n\n        raise ValueError(f\"Invalid metric target: {self._metric_target}\")\n\n    def _filter_detections_by_size(\n        self, detections: Detections, size_category: ObjectSizeCategory","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/precision.py#L515-L551","documentation":"Error \"Invalid metric target: {self._metric_target}\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/precision.py:533 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Construct Precision with a valid MetricTarget value.","Do not modify the internal metric target after construction."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}