mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.67k stars 1.31k forks source link

Tests with dependencies fail #1017

Closed TalLinzen closed 10 years ago

TalLinzen commented 10 years ago

I wanted to mention this for a while - the following two tests fail on my computer. I should probably install the dependencies (I actually do have sklearn but maybe not the right version). Anyway, perhaps the test shouldn't run if the dependency doesn't exist?

======================================================================
ERROR: Test time generalization decoding
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "/Users/tallinzen/Dropbox/mne-python/mne/decoding/tests/test_time_gen.py", line 40, in test_time_generalization
    scores = time_generalization(epochs_list, cv=2, random_state=42)
  File "<string>", line 2, in time_generalization
  File "/Users/tallinzen/Dropbox/mne-python/mne/utils.py", line 387, in verbose
    ret = function(*args, **kwargs)
  File "/Users/tallinzen/Dropbox/mne-python/mne/decoding/time_gen.py", line 121, in time_generalization
    for train, test in cv)
  File "/Users/tallinzen/Dropbox/mne-python/mne/decoding/time_gen.py", line 120, in <genexpr>
    scores = parallel(p_time_gen(clone(clf), X, y, train, test, scoring)
  File "/Users/tallinzen/Dropbox/mne-python/mne/decoding/time_gen.py", line 14, in _time_gen_one_fold
    from sklearn.metrics import SCORERS
ImportError: cannot import name SCORERS

======================================================================
ERROR: Test Yule-Walker against statsmodels
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/tallinzen/Dropbox/mne-python/mne/utils.py", line 533, in dec
    ret = function(*args, **kwargs)
  File "/Users/tallinzen/Dropbox/mne-python/mne/time_frequency/tests/test_ar.py", line 19, in test_yule_walker
    from statsmodels.regression.linear_model import yule_walker as sm_yw
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/regression/__init__.py", line 1, in <module>
    from linear_model import yule_walker
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/regression/linear_model.py", line 41, in <module>
    import statsmodels.base.model as base
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/base/model.py", line 10, in <module>
    from statsmodels.formula import handle_formula_data
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/formula/__init__.py", line 4, in <module>
    from formulatools import handle_formula_data
  File "/Users/tallinzen/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/formula/formulatools.py", line 2, in <module>
    from patsy import dmatrices
ImportError: No module named patsy
dengemann commented 10 years ago

@TalLinzen absolutely correct. Weak dependencies shall only be required if available, specific versions included. This needs a fix. Cf. mne/utils.py -- the various requires_* functions used as decorators.

larsoner commented 10 years ago

+1 yes please fix -- if you'd rather work on other things, let us know and someone else will pick it up. Shouldn't require too many new lines, though, so hopefully you don't mind.

BTW, thanks for finding issues like these -- they represent the sort of barriers that will prevent users from adopting new software.

agramfort commented 10 years ago

thanks

PR very welcome. Use a try catch ImportError to assess if statsmodels is properly installed. Regarding sklearn is means the test should require a more recent version of scikit learn. Version 0.14 I suppose.