Skip to content

Commit

Permalink
Test only if it is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
mwojcikowski committed Jun 11, 2018
1 parent 326fa97 commit 3dfa562
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions compiledtrees/tests/test_compiled.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3dfa562

Please sign in to comment.