Commit 0229c767 authored by Yannick DAYER's avatar Yannick DAYER

Test for the PAI separation in CSV score files

parent 211e5abe
Pipeline #51476 passed with stage
in 8 minutes and 25 seconds
This diff is collapsed.
from import datafile from import datafile
from import HDF5File from import HDF5File
from bob.pad.base.script.error_utils import ( from bob.pad.base.script.error_utils import (
negatives_per_pai_and_positives, split_csv_pad_per_pai,
apcer_bpcer, apcer_bpcer,
calc_threshold, calc_threshold,
) )
import nose import nose
import numpy as np import numpy as np
scores_dev = datafile("per_pai_scores/scores-dev", module=__name__) scores_dev = datafile("per_pai_scores/scores-dev.csv", module=__name__)
scores_dev_reference_mask = datafile( scores_dev_reference_mask = datafile(
"per_pai_scores/scores-dev-{i}.hdf5", module=__name__ "per_pai_scores/scores-dev-{i}.hdf5", module=__name__
) )
...@@ -37,7 +38,7 @@ def _read_dict(f, name): ...@@ -37,7 +38,7 @@ def _read_dict(f, name):
def test_per_pai_apcer(): def test_per_pai_apcer():
for i, regexps in enumerate((None, ["x[0-2]", "x[3-4]"], ["x[1-2]", "x[3-4]"])): for i, regexps in enumerate((None, ["x[0-2]", "x[3-4]"], ["x[1-2]", "x[3-4]"])):
try: try:
pos, negs = negatives_per_pai_and_positives(scores_dev, regexps) pos, negs = split_csv_pad_per_pai(scores_dev, regexps)
except ValueError: except ValueError:
if i == 2: if i == 2:
continue continue
...@@ -73,3 +74,10 @@ def test_per_pai_apcer(): ...@@ -73,3 +74,10 @@ def test_per_pai_apcer():, ref_negs), ref_negs), ref_thresholds), ref_thresholds), ref_metrics), ref_metrics)
def test_csv_split():
neg, pos = split_csv_pad(scores_dev)
assert len(neg) == 5000, len(neg)
assert len(pos) == 5000, len(pos)
assert np.isclose(np.mean(neg), -10, atol=0.1), np.mean(neg)
assert np.isclose(np.mean(pos), 10, atol=0.1), np.mean(pos)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment