(self)
| 49 | class TestUtils(unittest.TestCase): |
| 50 | |
| 51 | def test_check_class_labels(self): |
| 52 | for n_labels in range(1, 10): |
| 53 | for n_learners in range(1, 10): |
| 54 | # 1. test fitted estimators |
| 55 | labels = np.random.randint(10, size=n_labels) |
| 56 | different_labels = np.random.randint( |
| 57 | 10, 20, size=np.random.randint(1, 10)) |
| 58 | learner_list_1 = [mock.MockEstimator( |
| 59 | classes_=labels) for _ in range(n_learners)] |
| 60 | learner_list_2 = [mock.MockEstimator( |
| 61 | classes_=different_labels) for _ in range(np.random.randint(1, 5))] |
| 62 | shuffled_learners = random.sample( |
| 63 | learner_list_1 + learner_list_2, len(learner_list_1 + learner_list_2)) |
| 64 | self.assertTrue( |
| 65 | modAL.utils.validation.check_class_labels(*learner_list_1)) |
| 66 | self.assertFalse( |
| 67 | modAL.utils.validation.check_class_labels(*shuffled_learners)) |
| 68 | |
| 69 | # 2. test unfitted estimators |
| 70 | unfitted_learner_list = [mock.MockEstimator( |
| 71 | classes_=labels) for _ in range(n_learners)] |
| 72 | idx = np.random.randint(0, n_learners) |
| 73 | unfitted_learner_list.insert( |
| 74 | idx, mock.MockEstimator(fitted=False)) |
| 75 | self.assertRaises( |
| 76 | NotFittedError, modAL.utils.validation.check_class_labels, *unfitted_learner_list) |
| 77 | |
| 78 | def test_check_class_proba(self): |
| 79 | for n_labels in range(2, 20): |
nothing calls this directly
no outgoing calls
no test coverage detected