Repository: mne-tools/mne-python

Issue:
ENH: Test old versions of packages
We should have one of our Travis runs use the oldest versions of required deps we claim to support. I think it's easy with conda, I plan to take a crack at it this week sometime.



Discussion:

Resolving patch:
diff --git a/mne/utils.py b/mne/utils.py
--- a/mne/utils.py
+++ b/mne/utils.py
@@ -1560,6 +1560,14 @@ def clean_warning_registry():
     for mod in list(sys.modules.values()):
         if mod.__class__.__name__ not in bad_names and hasattr(mod, reg):
             getattr(mod, reg).clear()
+    # hack to deal with old scipy/numpy in tests
+    if os.getenv('TRAVIS') == 'true' and sys.version.startswith('2.6'):
+        warnings.simplefilter('default')
+        try:
+            np.rank([])
+        except Exception:
+            pass
+        warnings.simplefilter('always')
 
 
 def _check_type_picks(picks):


Test patch:
diff --git a/mne/beamformer/tests/test_dics.py b/mne/beamformer/tests/test_dics.py
--- a/mne/beamformer/tests/test_dics.py
+++ b/mne/beamformer/tests/test_dics.py
@@ -12,7 +12,7 @@
 from mne.beamformer import dics, dics_epochs, dics_source_power, tf_dics
 from mne.time_frequency import compute_epochs_csd
 from mne.externals.six import advance_iterator
-from mne.utils import run_tests_if_main
+from mne.utils import run_tests_if_main, clean_warning_registry
 
 # Note that this is the first test file, this will apply to all subsequent
 # tests in a full nosetest:
@@ -29,6 +29,9 @@
 label = 'Aud-lh'
 fname_label = op.join(data_path, 'MEG', 'sample', 'labels', '%s.label' % label)
 
+# bit of a hack to deal with old scipy/numpy throwing warnings in tests
+clean_warning_registry()
+
 
 def read_forward_solution_meg(*args, **kwargs):
     fwd = mne.read_forward_solution(*args, **kwargs)
diff --git a/mne/preprocessing/tests/test_infomax.py b/mne/preprocessing/tests/test_infomax.py
--- a/mne/preprocessing/tests/test_infomax.py
+++ b/mne/preprocessing/tests/test_infomax.py
@@ -86,7 +86,7 @@ def test_infomax_simple(add_noise=False):
 
 @requires_sklearn
 def test_non_square_infomax(add_noise=False):
-    """ Test the infomax algorithm on very simple data.
+    """ Test non-square infomax
     """
     from sklearn.decomposition import RandomizedPCA
 
diff --git a/mne/stats/tests/test_cluster_level.py b/mne/stats/tests/test_cluster_level.py
--- a/mne/stats/tests/test_cluster_level.py
+++ b/mne/stats/tests/test_cluster_level.py
@@ -410,6 +410,7 @@ def test_permutation_connectivity_equiv():
                 assert_array_equal(stat_map, this_stat_map)
 
 
+@slow_test
 def spatio_temporal_cluster_test_connectivity():
     """Test spatio-temporal cluster permutations
     """
diff --git a/mne/tests/test_cov.py b/mne/tests/test_cov.py
--- a/mne/tests/test_cov.py
+++ b/mne/tests/test_cov.py
@@ -133,6 +133,7 @@ def test_cov_estimation_on_raw_segment():
     assert_true(len(w) == 1)
 
 
+@slow_test
 def test_cov_estimation_with_triggers():
     """Test estimation from raw with triggers
     """
diff --git a/mne/tests/test_epochs.py b/mne/tests/test_epochs.py
--- a/mne/tests/test_epochs.py
+++ b/mne/tests/test_epochs.py
@@ -23,7 +23,8 @@
     bootstrap, equalize_epoch_counts, combine_event_ids, add_channels_epochs,
     EpochsArray, concatenate_epochs, _BaseEpochs)
 from mne.utils import (_TempDir, requires_pandas, requires_nitime, slow_test,
-                       clean_warning_registry, run_tests_if_main)
+                       clean_warning_registry, run_tests_if_main,
+                       requires_scipy_version)
 
 from mne.io.meas_info import create_info
 from mne.io.proj import _has_eeg_average_ref_proj
@@ -68,7 +69,8 @@ def test_base_epochs():
     assert_equal(epochs.__iter__()._current, 0)
 
 
-def test_filter():
+@requires_scipy_version('0.14')
+def test_savgol_filter():
     """Test savgol filtering
     """
     h_freq = 10.
diff --git a/mne/tests/test_evoked.py b/mne/tests/test_evoked.py
--- a/mne/tests/test_evoked.py
+++ b/mne/tests/test_evoked.py
@@ -20,7 +20,8 @@
 from mne.evoked import _get_peak, EvokedArray, merge_evoked
 from mne.epochs import EpochsArray
 
-from mne.utils import _TempDir, requires_pandas, requires_nitime, slow_test
+from mne.utils import (_TempDir, requires_pandas, requires_nitime, slow_test,
+                       requires_scipy_version)
 
 from mne.io.meas_info import create_info
 from mne.externals.six.moves import cPickle as pickle
@@ -33,7 +34,8 @@
                    'test-ave.fif.gz')
 
 
-def test_filter():
+@requires_scipy_version('0.14')
+def test_savgol_filter():
     """Test savgol filtering
     """
     h_freq = 10.
diff --git a/mne/viz/tests/test_circle.py b/mne/viz/tests/test_circle.py
--- a/mne/viz/tests/test_circle.py
+++ b/mne/viz/tests/test_circle.py
@@ -13,12 +13,12 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 
 def test_plot_connectivity_circle():
     """Test plotting connectivity circle
     """
+    import matplotlib.pyplot as plt
     node_order = ['frontalpole-lh', 'parsorbitalis-lh',
                   'lateralorbitofrontal-lh', 'rostralmiddlefrontal-lh',
                   'medialorbitofrontal-lh', 'parstriangularis-lh',
diff --git a/mne/viz/tests/test_epochs.py b/mne/viz/tests/test_epochs.py
--- a/mne/viz/tests/test_epochs.py
+++ b/mne/viz/tests/test_epochs.py
@@ -23,7 +23,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -76,6 +75,7 @@ def _get_epochs_delayed_ssp():
 def test_plot_epochs():
     """ Test plotting epochs
     """
+    import matplotlib.pyplot as plt
     epochs = _get_epochs()
     epochs.plot([0, 1], picks=[0, 2, 3], scalings=None, title_str='%s')
     epochs[0].plot(picks=[0, 2, 3], scalings=None, title_str='%s')
@@ -101,6 +101,7 @@ def test_plot_epochs():
 def test_plot_image_epochs():
     """Test plotting of epochs image
     """
+    import matplotlib.pyplot as plt
     epochs = _get_epochs()
     plot_image_epochs(epochs, picks=[1, 2])
     plt.close('all')
@@ -109,6 +110,7 @@ def test_plot_image_epochs():
 def test_plot_drop_log():
     """Test plotting a drop log
     """
+    import matplotlib.pyplot as plt
     epochs = _get_epochs()
     epochs.drop_bad_epochs()
 
diff --git a/mne/viz/tests/test_evoked.py b/mne/viz/tests/test_evoked.py
--- a/mne/viz/tests/test_evoked.py
+++ b/mne/viz/tests/test_evoked.py
@@ -21,7 +21,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -76,6 +75,7 @@ def _get_epochs_delayed_ssp():
 def test_plot_evoked():
     """Test plotting of evoked
     """
+    import matplotlib.pyplot as plt
     evoked = _get_epochs().average()
     with warnings.catch_warnings(record=True):
         evoked.plot(proj=True, hline=[1])
diff --git a/mne/viz/tests/test_ica.py b/mne/viz/tests/test_ica.py
--- a/mne/viz/tests/test_ica.py
+++ b/mne/viz/tests/test_ica.py
@@ -16,7 +16,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -53,6 +52,7 @@ def _get_epochs():
 def test_plot_ica_components():
     """Test plotting of ICA solutions
     """
+    import matplotlib.pyplot as plt
     raw = _get_raw()
     ica = ICA(noise_cov=read_cov(cov_fname), n_components=2,
               max_pca_components=3, n_pca_components=3)
@@ -71,6 +71,7 @@ def test_plot_ica_components():
 def test_plot_ica_sources():
     """Test plotting of ICA panel
     """
+    import matplotlib.pyplot as plt
     raw = io.Raw(raw_fname, preload=True)
     picks = _get_picks(raw)
     epochs = _get_epochs()
@@ -91,6 +92,7 @@ def test_plot_ica_sources():
 def test_plot_ica_overlay():
     """Test plotting of ICA cleaning
     """
+    import matplotlib.pyplot as plt
     raw = _get_raw(preload=True)
     picks = _get_picks(raw)
     ica = ICA(noise_cov=read_cov(cov_fname), n_components=2,
@@ -110,6 +112,7 @@ def test_plot_ica_overlay():
 def test_plot_ica_scores():
     """Test plotting of ICA scores
     """
+    import matplotlib.pyplot as plt
     raw = _get_raw()
     picks = _get_picks(raw)
     ica = ICA(noise_cov=read_cov(cov_fname), n_components=2,
diff --git a/mne/viz/tests/test_misc.py b/mne/viz/tests/test_misc.py
--- a/mne/viz/tests/test_misc.py
+++ b/mne/viz/tests/test_misc.py
@@ -24,7 +24,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -53,7 +52,6 @@ def test_plot_cov():
     raw = _get_raw()
     cov = read_cov(cov_fname)
     fig1, fig2 = cov.plot(raw.info, proj=True, exclude=raw.ch_names[6:])
-    plt.close('all')
 
 
 @testing.requires_testing_data
diff --git a/mne/viz/tests/test_raw.py b/mne/viz/tests/test_raw.py
--- a/mne/viz/tests/test_raw.py
+++ b/mne/viz/tests/test_raw.py
@@ -13,7 +13,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -49,6 +48,7 @@ def _get_events():
 def test_plot_raw():
     """Test plotting of raw data
     """
+    import matplotlib.pyplot as plt
     raw = _get_raw()
     events = _get_events()
     plt.close('all')  # ensure all are closed
diff --git a/mne/viz/tests/test_topo.py b/mne/viz/tests/test_topo.py
--- a/mne/viz/tests/test_topo.py
+++ b/mne/viz/tests/test_topo.py
@@ -24,7 +24,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -99,6 +98,7 @@ def test_plot_topo():
 def test_plot_topo_image_epochs():
     """Test plotting of epochs image topography
     """
+    import matplotlib.pyplot as plt
     title = 'ERF images - MNE sample data'
     epochs = _get_epochs()
     plot_topo_image_epochs(epochs, layout, sigma=0.5, vmin=-200, vmax=200,
diff --git a/mne/viz/tests/test_topomap.py b/mne/viz/tests/test_topomap.py
--- a/mne/viz/tests/test_topomap.py
+++ b/mne/viz/tests/test_topomap.py
@@ -27,8 +27,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
-from matplotlib.patches import Circle  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -54,6 +52,8 @@ def _get_raw():
 def test_plot_topomap():
     """Test topomap plotting
     """
+    import matplotlib.pyplot as plt
+    from matplotlib.patches import Circle
     # evoked
     warnings.simplefilter('always', UserWarning)
     res = 16
diff --git a/mne/viz/tests/test_utils.py b/mne/viz/tests/test_utils.py
--- a/mne/viz/tests/test_utils.py
+++ b/mne/viz/tests/test_utils.py
@@ -10,7 +10,6 @@
 # Set our plotters to test mode
 import matplotlib
 matplotlib.use('Agg')  # for testing don't use X server
-import matplotlib.pyplot as plt  # noqa
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
 
@@ -22,5 +21,6 @@
 def test_compare_fiff():
     """Test comparing fiff files
     """
+    import matplotlib.pyplot as plt
     compare_fiff(raw_fname, cov_fname, read_limit=0, show=False)
     plt.close('all')