def test_get_scores_and_labels(self):
        benchmark_scores = np.array(
            (0.5, 0.6, 0.5, 0.0, 0.1, 0.2, 0.3, 0.3, 0.3))
        benchmark_labels = np.array((0, 0, 0, 1, 1, 1, 2, 2, 2))

        scores_container = ScoresContainer(self.scores, self.labels)

        scores, labels = scores_container.get_scores_and_labels()

        np.testing.assert_array_equal(scores, benchmark_scores)
        np.testing.assert_array_equal(labels, benchmark_labels)
Beispiel #2
0
    def test_data_error(self):
        metrics = 'EER'
        scores_container = ScoresContainer(np.array([]), np.array([]))

        self.assertRaises(
            TypeError,
            lambda: PerformanceExtractor.run(metrics, scores_container))
Beispiel #3
0
    def test_eer(self):
        metrics = 'EER'
        scores_container = ScoresContainer(self.scores, self.labels)

        performance = PerformanceExtractor.run(metrics, scores_container)

        self.assertEquals({'threshold': 0.55, 'value': 0.0}, performance)
class UnitSubsetData(unittest.TestCase):

    pad_info = PadInfo('all_attacks', 15, 1000)
    scores_container = ScoresContainer(
        np.array((0.5, 0.6, 0.5)),  # genuine
        np.array((0.0, 0.1, 0.2)))  # impostor
    pad_data = PadData(pad_info, scores_container)

    parameters_grid = list(
        ParameterGrid({
            'attack': ['all_attacks', ['print'], ['replay']],
            'framerate': [10, 15, 20],
            'time_capture': [1000, 2000]
        }))
    list_pad_data = [pad_data, pad_data]

    def test_constructor(self):

        subset_data = SubsetData(self.parameters_grid, self.list_pad_data)

        self.assertEqual(subset_data.parameters_grid, self.parameters_grid)
        self.assertEqual(subset_data.list_pad_data, self.list_pad_data)

    def test_print(self):
        subset_data = SubsetData(self.parameters_grid, self.list_pad_data)

        self.assertEqual(
            subset_data.__str__(),
            'SubsetData : len(parameters_grid) : 18 , len(list_pad_data) : 2')

    def test_empty_list_attacks(self):

        self.assertRaises(TypeError,
                          lambda: SubsetData(None, self.list_pad_data))

    def test_empty_list_pad_data(self):
        self.assertRaises(TypeError,
                          lambda: SubsetData(self.parameters_grid, None))
class UnitTestPadData(unittest.TestCase):

    pad_info = PadInfo('all_attacks', 15, 1000)
    scores_container = ScoresContainer(
        np.array((0.5, 0.6, 0.5, 0.0, 0.1, 0.2)), np.array((0, 0, 0, 1, 1, 1)))

    def test_constructor(self):

        pad_data = PadData(self.pad_info, self.scores_container)

        self.assertEqual(pad_data.pad_info, self.pad_info)
        self.assertEqual(pad_data.scores_container, self.scores_container)

    def test_print(self):
        pad_data = PadData(self.pad_info, self.scores_container)
        # self.assertEqual(pad_data.__str__(),'PadData : PadInfo : type_attacks : all_attacks, framerate : 15, time_capture : 1000 , ScoresContainer : scores [0.5 0.6 0.5 0.  0.1 0.2], labels [0 0 0 1 1 1]')

    def test_empty_pad_info(self):
        self.assertRaises(TypeError,
                          lambda: PadData(None, self.scores_container))

    def test_empty_scores_container(self):
        self.assertRaises(TypeError, lambda: PadData(self.pad_info, None))
 def test_print(self):
     scores_container = ScoresContainer(self.scores, self.labels)
    def test_constructor(self):
        scores_container = ScoresContainer(self.scores, self.labels)

        np.testing.assert_array_equal(scores_container.scores, self.scores)
        np.testing.assert_array_equal(scores_container.labels, self.labels)