def test_all_labels_are_chosen_twice(self): r = chose_examples(self.labels, self.label_set, number=2) lab = [self.labels[i] for i in r] assert (all([lab.count(l) == 2 for l in self.label_set]))
def test_all_chosen_are_indices(self): r = chose_examples(self.labels, self.label_set, number=2) assert (all([0 <= i < len(self.labels) for i in r]))
def test_all_labels_are_chosen_once(self): r = chose_examples(self.labels, self.label_set) lab = [self.labels[i] for i in r] assert (all([lab.count(l) == 1 for l in self.label_set]))
def test_choses_as_many_examples_as_labels(self): r = chose_examples(self.labels, self.label_set) self.assertEqual(len(r), len(self.label_set)) r = chose_examples(self.labels) # And without giving labels self.assertEqual(len(r), len(self.label_set))
def test_choses_twice_as_many_examples_as_labels(self): r = chose_examples(self.labels, self.label_set, number=2) self.assertEqual(len(r), 2 * len(self.label_set))
def test_all_labels_are_chosen_twice(self): r = chose_examples(self.labels, self.label_set, number=2) lab = [self.labels[i] for i in r] assert(all([lab.count(l) == 2 for l in self.label_set]))
def test_all_labels_are_chosen_once(self): r = chose_examples(self.labels, self.label_set) lab = [self.labels[i] for i in r] assert(all([lab.count(l) == 1 for l in self.label_set]))
def test_all_chosen_are_indices(self): r = chose_examples(self.labels, self.label_set, number=2) assert(all([0 <= i < len(self.labels) for i in r]))