|
9 | 9 | import numpy as np |
10 | 10 | import numpy.ma as npma |
11 | 11 |
|
| 12 | +from joblib import cpu_count |
| 13 | + |
12 | 14 | import autosklearn.pipeline.util as putil |
| 15 | +import autosklearn.estimators # noqa F401 |
13 | 16 | from autosklearn.estimators import AutoSklearnEstimator |
14 | 17 | from autosklearn.classification import AutoSklearnClassifier |
15 | 18 | from autosklearn.regression import AutoSklearnRegressor |
16 | 19 | from autosklearn.metrics import accuracy, f1_macro, mean_squared_error |
17 | 20 | from autosklearn.automl import AutoMLClassifier, AutoML |
18 | 21 | from autosklearn.util.backend import Backend, BackendContext |
19 | 22 | from autosklearn.constants import BINARY_CLASSIFICATION |
20 | | -sys.path.append(os.path.dirname(__file__)) |
21 | 23 | from base import Base |
22 | 24 |
|
| 25 | +sys.path.append(os.path.dirname(__file__)) |
23 | 26 |
|
24 | 27 | class ArrayReturningDummyPredictor(object): |
25 | 28 | def __init__(self, test): |
@@ -479,6 +482,17 @@ def test_fit_n_jobs_2(self): |
479 | 482 |
|
480 | 483 | self.assertEqual(len(seeds), 1) |
481 | 484 |
|
| 485 | + @unittest.mock.patch('autosklearn.estimators.AutoSklearnEstimator.build_automl') |
| 486 | + def test_fit_n_jobs_negative(self, build_automl_patch): |
| 487 | + n_cores = cpu_count() |
| 488 | + cls = AutoSklearnEstimator(n_jobs=-1) |
| 489 | + cls.fit() |
| 490 | + self.assertEqual(len(cls._automl), n_cores) |
| 491 | + |
| 492 | + def test_get_number_of_available_cores(self): |
| 493 | + n_cores = cpu_count() |
| 494 | + self.assertGreaterEqual(n_cores, 1) |
| 495 | + |
482 | 496 |
|
483 | 497 | class AutoMLClassifierTest(Base, unittest.TestCase): |
484 | 498 | @unittest.mock.patch('autosklearn.automl.AutoML.predict') |
|
0 commit comments