diff --git a/compiledtrees/tests/test_compiled.py b/compiledtrees/tests/test_compiled.py index 79a122f..8987a85 100644 --- a/compiledtrees/tests/test_compiled.py +++ b/compiledtrees/tests/test_compiled.py @@ -5,6 +5,7 @@ import os from sklearn import ensemble, tree from compiledtrees.compiled import CompiledRegressionPredictor +from compiledtrees.code_gen import OPENMP_SUPPORT from sklearn.utils.testing import (assert_array_almost_equal, assert_raises, assert_equal, assert_allclose, @@ -145,22 +146,23 @@ def test_openmp(self): rf1_compiled.predict(X1, n_jobs=2), decimal=10) - # On travis/appveyor check for any speedup Be less generous otherwise. - if 'TRAVIS' in os.environ or 'APPVEYOR' in os.environ: - target = 0.9 - else: - target = 0.6 - # multi sample scaling - parallel samples - start = datetime.now() - rf1_compiled.predict(X1, n_jobs=1) - t_single = (datetime.now() - start).microseconds - - start = datetime.now() - rf1_compiled.predict(X1, n_jobs=2) - t_double = (datetime.now() - start).microseconds - - # ensure almost linear speedup, 0.5 = liear - assert_greater(target, t_double / t_single) # Parallel samples + if OPENMP_SUPPORT: + # On travis/appveyor check for any speedup Be less generous otherwise. + if 'TRAVIS' in os.environ or 'APPVEYOR' in os.environ: + target = 0.9 + else: + target = 0.6 + # multi sample scaling - parallel samples + start = datetime.now() + rf1_compiled.predict(X1, n_jobs=1) + t_single = (datetime.now() - start).microseconds + + start = datetime.now() + rf1_compiled.predict(X1, n_jobs=2) + t_double = (datetime.now() - start).microseconds + + # ensure almost linear speedup, 0.5 = liear + assert_greater(target, t_double / t_single) # Parallel samples def test_predictions_with_invalid_input(self): num_features = 100