Files
anomalib/tests/unit/metrics/test_precision_recall.py
zeekay dda5b2a367 restore the tree
The previous commit was meant to remove .github/workflows and removed
every tracked path instead — 892 files, the whole repo. This puts back
the 874 that were never in scope; the eighteen workflow files stay gone,
for the reasons that commit gives.

Content is byte-identical to 9d2aec9 outside .github/workflows.
2026-08-13 23:27:57 -07:00

19 lines
625 B
Python

"""Tests custom precision recall metric."""
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import torch
from anomalib.metrics import BinaryPrecisionRecallCurve
def test_precision_recall() -> None:
"""Test if the precision recall computation returns the desired value."""
targets = torch.tensor([0, 0, 1, 0, 1, 1], dtype=torch.int)
predictions = torch.tensor([12, 13, 14, 15, 16, 17])
metric = BinaryPrecisionRecallCurve()
metric.update(predictions, targets)
_, _, thresholds = metric.compute()
assert (thresholds == torch.tensor([12, 13, 14, 15, 16, 17])).all()