# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch> # # SPDX-License-Identifier: GPL-3.0-or-later """Tests for measure functions.""" import numpy def test_centered_maxf1(): from ptbench.engine.evaluator import _get_centered_maxf1 # Multiple max F1 f1_scores = numpy.array([0.8, 0.9, 1.0, 1.0, 1.0, 0.3]) thresholds = numpy.array([0.2, 0.3, 0.4, 0.5, 0.6, 0.7]) maxf1, threshold = _get_centered_maxf1(f1_scores, thresholds) assert maxf1 == 1.0 assert threshold == 0.5 # Single max F1 f1_scores = numpy.array([0.8, 0.9, 1.0, 0.9, 0.7, 0.3]) thresholds = numpy.array([0.2, 0.3, 0.4, 0.5, 0.6, 0.7]) maxf1, threshold = _get_centered_maxf1(f1_scores, thresholds) assert maxf1 == 1.0 assert threshold == 0.4