Tests for the base class methods of the BaseLearner (base.py) are provided in the TestActiveLearner.
| 880 | |
| 881 | |
| 882 | class TestDeepActiveLearner(unittest.TestCase): |
| 883 | """ |
| 884 | Tests for the base class methods of the BaseLearner (base.py) are provided in |
| 885 | the TestActiveLearner. |
| 886 | """ |
| 887 | |
| 888 | def setUp(self): |
| 889 | self.mock_deep_estimator = mock.MockEstimator() |
| 890 | # Add methods that can not be autospecced (because of the wrapper) |
| 891 | self.mock_deep_estimator.initialize = MagicMock(name='initialize') |
| 892 | self.mock_deep_estimator.partial_fit = MagicMock(name='partial_fit') |
| 893 | |
| 894 | def test_teach(self): |
| 895 | |
| 896 | for bootstrap, warm_start in product([True, False], [True, False]): |
| 897 | for n_samples in range(1, 10): |
| 898 | X = torch.randn(n_samples, 1) |
| 899 | y = torch.randn(n_samples) |
| 900 | |
| 901 | learner = modAL.models.learners.DeepActiveLearner( |
| 902 | estimator=self.mock_deep_estimator |
| 903 | ) |
| 904 | |
| 905 | learner.teach(X, y, bootstrap=bootstrap, warm_start=warm_start) |
| 906 | |
| 907 | def test_batch_size(self): |
| 908 | learner = modAL.models.learners.DeepActiveLearner( |
| 909 | estimator=self.mock_deep_estimator |
| 910 | ) |
| 911 | |
| 912 | for batch_size in range(1, 50): |
| 913 | learner.batch_size = batch_size |
| 914 | self.assertEqual(batch_size, learner.batch_size) |
| 915 | |
| 916 | def test_num_epochs(self): |
| 917 | learner = modAL.models.learners.DeepActiveLearner( |
| 918 | estimator=self.mock_deep_estimator |
| 919 | ) |
| 920 | |
| 921 | for num_epochs in range(1, 50): |
| 922 | learner.num_epochs = num_epochs |
| 923 | self.assertEqual(num_epochs, learner.num_epochs) |
| 924 | |
| 925 | |
| 926 | class TestActiveLearner(unittest.TestCase): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…