From 725cdfcc028a91225487fc6c63b15bd1cb3c6130 Mon Sep 17 00:00:00 2001 From: Jonathan de Bruin Date: Wed, 15 Jun 2022 12:15:53 +0200 Subject: [PATCH] Fix prior not included when priors=True (#36) --- asreviewcontrib/insights/metrics.py | 6 +++--- tests/test_metrics.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/asreviewcontrib/insights/metrics.py b/asreviewcontrib/insights/metrics.py index ecc9ed4..b503b74 100644 --- a/asreviewcontrib/insights/metrics.py +++ b/asreviewcontrib/insights/metrics.py @@ -40,7 +40,7 @@ def recall(state_obj, x_absolute=False, y_absolute=False): - labels = get_labels(state_obj) + labels = get_labels(state_obj, priors=priors) return _recall(labels, intercept, @@ -64,7 +64,7 @@ def wss(state_obj, x_absolute=False, y_absolute=False): - labels = get_labels(state_obj) + labels = get_labels(state_obj, priors=priors) return _wss(labels, intercept, @@ -85,7 +85,7 @@ def erf(state_obj, x_absolute=False, y_absolute=False): - labels = get_labels(state_obj) + labels = get_labels(state_obj, priors=priors) return _erf(labels, intercept, diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 6ef15ff..2854a93 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -1,6 +1,7 @@ from pathlib import Path from asreview import open_state +from numpy import array_equal from numpy.testing import assert_almost_equal from asreviewcontrib.insights.metrics import _recall @@ -84,3 +85,15 @@ def test_metric_recall(): "sim_van_de_schoot_2017_1.asreview")) as s: assert_almost_equal(recall(s, 0.25), 1) + + +def test_metric_priors(): + + with open_state( + Path(TEST_ASREVIEW_FILES, + "sim_van_de_schoot_2017_1.asreview")) as s: + + r_priors = recall(s, 0.01, priors=True) + r_no_priors = recall(s, 0.01, priors=False) + + assert not array_equal(r_priors, r_no_priors)