Skip to content

Commit

Permalink
Merge pull request #47 from egbn17/master
Browse files Browse the repository at this point in the history
FIX: scitkits error + testing
  • Loading branch information
Stewori committed Jul 3, 2019
2 parents b711200 + 3d33d50 commit a39fb50
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 17 deletions.
75 changes: 64 additions & 11 deletions .travis.yml
Expand Up @@ -6,36 +6,89 @@
# I would prefer to test against what is in neurodebian
language: python
python:
- "2.7"
- "3.5"
- "3.5-dev" # 3.5 development branch
- "3.6"
- "3.6-dev" # 3.6 development branch
- "3.7-dev" # 3.7 development branch
env:
- VNUMPY=1.8.2
- VNUMPY=1.12.1
- VNUMPY=1.16.1
- VNUMPY=1.8.2 VSCI=0.21.2
- VNUMPY=1.8.2 VSCI=0.20.0
- VNUMPY=1.8.2 VSCI=0.18
- VNUMPY=1.12.1 VSCI=0.21.2
- VNUMPY=1.12.1 VSCI=0.20.0
- VNUMPY=1.12.1 VSCI=0.18
- VNUMPY=1.16.1 VSCI=0.21.2
- VNUMPY=1.16.1 VSCI=0.20.0
- VNUMPY=1.16.1 VSCI=0.18

cache:
- apt
matrix:
# old numpy + new python has problems setting up
include:
- python: "2.7"
env: VNUMPY=1.7.1 VSCI=0.14
- python: "2.7"
env: VNUMPY=1.8.2 VSCI=0.19.2
- python: "2.7"
env: VNUMPY=1.16.1 VSCI=0.14
- python: "2.7"
env: VNUMPY=1.16.1 VSCI=0.19.2

# old packagese + new python has problems setting up
exclude:
- python: "3.7-dev"
env: VNUMPY=1.8.2
env: VNUMPY=1.8.2 VSCI=0.21.2
- python: "3.7-dev"
env: VNUMPY=1.8.2 VSCI=0.20.0
- python: "3.7-dev"
env: VNUMPY=1.8.2 VSCI=0.18
- python: "3.7-dev"
env: VNUMPY=1.12.1 VSCI=0.21.2
- python: "3.7-dev"
env: VNUMPY=1.12.1
env: VNUMPY=1.12.1 VSCI=0.20.0
- python: "3.7-dev"
env: VNUMPY=1.12.1 VSCI=0.18
- python: "3.7-dev"
env: VNUMPY=1.16.1 VSCI=0.18
- python: "3.6-dev"
env: VNUMPY=1.8.2 VSCI=0.21.2
- python: "3.6-dev"
env: VNUMPY=1.8.2 VSCI=0.20.0
- python: "3.6-dev"
env: VNUMPY=1.8.2
env: VNUMPY=1.8.2 VSCI=0.18
- python: "3.6-dev"
env: VNUMPY=1.12.1 VSCI=0.18
- python: "3.6-dev"
env: VNUMPY=1.16.1 VSCI=0.18
- python: "3.6"
env: VNUMPY=1.8.2 VSCI=0.21.2
- python: "3.6"
env: VNUMPY=1.8.2 VSCI=0.20.0
- python: "3.6"
env: VNUMPY=1.8.2
env: VNUMPY=1.8.2 VSCI=0.18
- python: "3.6"
env: VNUMPY=1.12.1 VSCI=0.18
- python: "3.6"
env: VNUMPY=1.16.1 VSCI=0.18
- python: "3.5-dev"
env: VNUMPY=1.8.2 VSCI=0.21.2
- python: "3.5-dev"
env: VNUMPY=1.8.2 VSCI=0.20.0
- python: "3.5"
env: VNUMPY=1.8.2 VSCI=0.21.2
- python: "3.5"
env: VNUMPY=1.8.2 VSCI=0.20.0



before_install:
# The ultimate one-liner setup for NeuroDebian repository
- bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh)
- travis_retry sudo apt-get install python-joblib python-sklearn
- travis_retry sudo apt-get install python-joblib
install:
- pip install -v numpy==$VNUMPY
- pip install scipy
- pip install -v numpy==$VNUMPY scikit-learn==$VSCI
- pip install -v pytest==4.0.0 pytest-cov>=2.5.0 coveralls future
script:
- pytest --cov-report= --cov-config=.coveragerc --cov=mdp --seed=725021957 mdp
Expand Down
24 changes: 21 additions & 3 deletions mdp/test/test_nodes_generic.py
Expand Up @@ -192,6 +192,12 @@ def test_dtype_consistency(klass, init_args, inp_arg_gen,
supported_types = klass(*args).get_supported_dtypes()
for dtype in supported_types:
inp = inp_arg_gen()
# The code was written before the following was included in
# scikit-learn. If more new nodes show up, that require the
# following fix, switch to a more generic solution.
# See: https://github.com/mdp-toolkit/mdp-toolkit/pull/47
if klass.__name__ == "ComplementNBScikitsLearnNode":
inp = numx.absolute(inp)
args = call_init_args(init_args)
node = klass(dtype=dtype, *args)
_train_if_necessary(inp, node, sup_arg_gen)
Expand All @@ -210,6 +216,12 @@ def test_outputdim_consistency(klass, init_args, inp_arg_gen,
sup_arg_gen, execute_arg_gen):
args = call_init_args(init_args)
inp = inp_arg_gen()
# The code was written before the following was included in
# scikit-learn. If more new nodes show up, that require the
# following fix, switch to a more generic solution.
# See: https://github.com/mdp-toolkit/mdp-toolkit/pull/47
if klass.__name__ == "ComplementNBScikitsLearnNode":
inp = numx.absolute(inp)
# support generators
if isinstance(inp, Iter):
for x in inp:
Expand Down Expand Up @@ -250,16 +262,16 @@ def _test(node):
# raises an appropriate error
# case 1: both in the constructor
pytest.raises(InconsistentDimException,
'klass(input_dim=inp.shape[1], output_dim=output_dim, *args)')
'klass(input_dim=inp.shape[1], output_dim=output_dim, *args)')
# case 2: first input_dim, then output_dim
node = klass(input_dim=inp.shape[1], *args)
pytest.raises(InconsistentDimException,
'node.output_dim = output_dim')
'node.output_dim = output_dim')
# case 3: first output_dim, then input_dim
node = klass(output_dim=output_dim, *args)
node.output_dim = output_dim
pytest.raises(InconsistentDimException,
'node.input_dim = inp.shape[1]')
'node.input_dim = inp.shape[1]')

# check that output_dim is set to whatever the output dim is
node = klass(*args)
Expand All @@ -278,6 +290,12 @@ def test_dimdtypeset(klass, init_args, inp_arg_gen,
sup_arg_gen, execute_arg_gen):
init_args = call_init_args(init_args)
inp = inp_arg_gen()
# The code was written before the following was included in
# scikit-learn. If more new nodes show up, that require the
# following fix, switch to a more generic solution.
# See: https://github.com/mdp-toolkit/mdp-toolkit/pull/47
if klass.__name__ == "ComplementNBScikitsLearnNode":
inp = numx.absolute(inp)
node = klass(*init_args)
_train_if_necessary(inp, node, sup_arg_gen)
_stop_training_or_execute(node, inp)
Expand Down
6 changes: 3 additions & 3 deletions testall.py
Expand Up @@ -7,9 +7,9 @@
# $ python testall.py /home/tiziano/python/x86_64/lib/pythonVERSION/site-packages

PARMS = {
'3.4': ('numpy', None, 'joblib', 'scikits'),
'3.5': ('numpy', None, 'joblib', 'scikits'),
'2.7': ('scipy', None, 'parallel_python', 'libsvm', 'joblib', 'scikits'),
'3.4': ('numpy', None, 'joblib', 'scikit-learn'),
'3.5': ('numpy', None, 'joblib', 'scikit-learn'),
'2.7': ('scipy', None, 'parallel_python', 'libsvm', 'joblib', 'scikit-learn'),
}

import os
Expand Down

0 comments on commit a39fb50

Please sign in to comment.