[med-svn] [mne-python] 01/03: Imported Upstream version 0.7~rc4

Andreas Tille tille at debian.org
Sat Nov 23 23:06:43 UTC 2013


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository mne-python.

commit 3943434cbe9061efe5cc08b072d978d16ff104bb
Author: Andreas Tille <tille at debian.org>
Date:   Sat Nov 23 23:10:13 2013 +0100

    Imported Upstream version 0.7~rc4
---
 mne/datasets/sample/sample.py       |  9 +++------
 mne/datasets/utils.py               | 19 ++++++++++---------
 mne/tests/test_utils.py             |  4 ++--
 mne/time_frequency/tests/test_ar.py | 19 +++++++++----------
 mne/utils.py                        | 21 +++++++++++++++++++++
 mne/viz.py                          |  2 +-
 6 files changed, 46 insertions(+), 28 deletions(-)

diff --git a/mne/datasets/sample/sample.py b/mne/datasets/sample/sample.py
index 8a2eb30..560dad0 100644
--- a/mne/datasets/sample/sample.py
+++ b/mne/datasets/sample/sample.py
@@ -6,11 +6,8 @@
 import numpy as np
 
 from ...utils import get_config, verbose
-from ...fixes import partial
 from ..utils import has_dataset, _data_path, _doc
 
-has_sample_data = partial(has_dataset, name='sample')
-
 @verbose
 def data_path(path=None, force_update=False, update_path=True,
               download=True, verbose=None):
@@ -26,6 +23,6 @@ data_path.__doc__ = _doc.format(name='sample',
 # `make test-no-sample`
 has_sample_data = has_dataset('sample')
 skip_sample = get_config('MNE_SKIP_SAMPLE_DATASET_TESTS', 'false') == 'true'
-requires_sample_data = np.testing.dec.skipif(not has_sample_data
-                                          or skip_sample,
-                                          'Requires sample dataset')
+requires_sample_data = np.testing.dec.skipif(not has_dataset('sample')
+                                             or skip_sample,
+                                             'Requires sample dataset')
diff --git a/mne/datasets/utils.py b/mne/datasets/utils.py
index 6b24081..1fd8c2b 100644
--- a/mne/datasets/utils.py
+++ b/mne/datasets/utils.py
@@ -55,8 +55,8 @@ def _dataset_version(path, name):
         fid.close()
     else:
         # Sample dataset versioning was introduced after 0.3
-        # SPM dataset was introduced after 0.6
-        version = '0.3' if name == 'sample' else '0.6'
+        # SPM dataset was introduced with 0.7
+        version = '0.3' if name == 'sample' else '0.7'
 
     return version
 
@@ -161,16 +161,17 @@ def _data_path(path=None, force_update=False, update_path=True,
     # compare the version of the Sample dataset and mne
     data_version = _dataset_version(path, name)
     try:
-        from distutils.version import LooseVersion
+        from distutils.version import LooseVersion as LV
     except:
         warn('Could not determine sample dataset version; dataset could\n'
              'be out of date. Please install the "distutils" package.')
-    else:
-        if LooseVersion(data_version) < LooseVersion(mne_version):
-            warn('Sample dataset (version %s) is older than mne-python '
-                 '(version %s). If the examples fail, you may need to update '
-                 'the sample dataset by using force_update=True'
-                 % (data_version, mne_version))
+    else:  # 0.7 < 0.7.git shoud be False, therefore strip
+        if LV(data_version) < LV(mne_version.strip('.git')):
+            warn('The {name} dataset (version {current}) is older than '
+                 'the mne-python (version {newest}). If the examples fail, '
+                 'you may need to update the {name} dataset by using'
+                 'force_update=True'.format(name=name, current=data_version,
+                                            newest=mne_version))
 
     return path
 
diff --git a/mne/tests/test_utils.py b/mne/tests/test_utils.py
index cad5074..201a6a0 100644
--- a/mne/tests/test_utils.py
+++ b/mne/tests/test_utils.py
@@ -204,7 +204,7 @@ def test_fetch_file():
     """
     # Skipping test if no internet connection available
     try:
-        urllib2.urlopen("http://github.com", timeout=1)
+        urllib2.urlopen("http://github.com", timeout=2)
     except urllib2.URLError:
         from nose.plugins.skip import SkipTest
         raise SkipTest('No internet connection, skipping download test.')
@@ -214,7 +214,7 @@ def test_fetch_file():
     for url in urls:
         archive_name = op.join(tempdir, "download_test")
         _fetch_file(url, archive_name, print_destination=False)
-        assert_raises(Exception, _fetch_file, 'http://0.0',
+        assert_raises(Exception, _fetch_file, 'NOT_AN_ADDRESS',
                       op.join(tempdir, 'test'))
         resume_name = op.join(tempdir, "download_resume")
         # touch file
diff --git a/mne/time_frequency/tests/test_ar.py b/mne/time_frequency/tests/test_ar.py
index b8003fe..a8dcf2a 100644
--- a/mne/time_frequency/tests/test_ar.py
+++ b/mne/time_frequency/tests/test_ar.py
@@ -2,27 +2,26 @@ import os.path as op
 import numpy as np
 from numpy.testing import assert_array_almost_equal
 from nose.tools import assert_true
-import nose
 
 from mne import fiff
 from mne.time_frequency import yule_walker, ar_raw
+from mne.utils import requires_statsmodels
+
 
 raw_fname = op.join(op.dirname(__file__), '..', '..', 'fiff', 'tests', 'data',
                     'test_raw.fif')
 
 
+ at requires_statsmodels
 def test_yule_walker():
     """Test Yule-Walker against statsmodels
     """
-    try:
-        from statsmodels.regression.linear_model import yule_walker as sm_yw
-        d = np.random.randn(100)
-        sm_rho, sm_sigma = sm_yw(d, order=2)
-        rho, sigma = yule_walker(d, order=2)
-        assert_array_almost_equal(sm_sigma, sigma)
-        assert_array_almost_equal(sm_rho, rho)
-    except ImportError:
-        raise nose.SkipTest("XFailed Test")
+    from statsmodels.regression.linear_model import yule_walker as sm_yw
+    d = np.random.randn(100)
+    sm_rho, sm_sigma = sm_yw(d, order=2)
+    rho, sigma = yule_walker(d, order=2)
+    assert_array_almost_equal(sm_sigma, sigma)
+    assert_array_almost_equal(sm_rho, rho)
 
 
 def test_ar_raw():
diff --git a/mne/utils.py b/mne/utils.py
index 04e053c..003421d 100644
--- a/mne/utils.py
+++ b/mne/utils.py
@@ -507,6 +507,27 @@ def requires_tvtk(function):
     return dec
 
 
+def requires_statsmodels(function):
+    """Decorator to skip test if statsmodels is not available"""
+    @wraps(function)
+    def dec(*args, **kwargs):
+        skip = False
+        try:
+            from tvtk.api import tvtk  # analysis:ignore
+        except ImportError:
+            skip = True
+
+        if skip is True:
+            from nose.plugins.skip import SkipTest
+            raise SkipTest('Test %s skipped, requires statsmodels'
+                           % function.__name__)
+        ret = function(*args, **kwargs)
+
+        return ret
+
+    return dec
+
+
 def make_skipper_dec(module, skip_str):
     """Helper to make skipping decorators"""
     skip = False
diff --git a/mne/viz.py b/mne/viz.py
index b290ff4..9d41570 100644
--- a/mne/viz.py
+++ b/mne/viz.py
@@ -3485,7 +3485,7 @@ def plot_source_spectrogram(stcs, freq_bins, source_index=None, colorbar=False,
     # Covering frequency gaps with horizontal bars
     for lower_bound, upper_bound in gap_bounds:
         plt.barh(lower_bound, time_bounds[-1] - time_bounds[0], upper_bound -
-                 lower_bound, time_bounds[0], color='lightgray')
+                 lower_bound, time_bounds[0], color='#666666')
 
     if show:
         plt.show()

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/mne-python.git



More information about the debian-med-commit mailing list