Repository: mne-tools/mne-python

Issue:
Q: Dataset versions
Have we gotten any useful information from embedding dataset versions in our tarballs? As far as I can tell it has just led to a bunch of warnings when doing imports (see e.g. Mainak's recent notebook examples). I propose we get rid of them for now, and replace them with a new system in the future if need be. But for now I think it's beyond YAGNI and into the adding-annoyance category...

Discussion:

Patch:
diff --git a/mne/datasets/sample/__init__.py b/mne/datasets/sample/__init__.py
index 1a278cfcc..3e4de83f4 100644
--- a/mne/datasets/sample/__init__.py
+++ b/mne/datasets/sample/__init__.py
@@ -1,4 +1,4 @@
 """MNE sample dataset
 """
 
-from .sample import data_path, has_sample_data
+from .sample import data_path, has_sample_data, get_version
diff --git a/mne/datasets/sample/sample.py b/mne/datasets/sample/sample.py
index 87ed46446..15d4b1281 100644
--- a/mne/datasets/sample/sample.py
+++ b/mne/datasets/sample/sample.py
@@ -5,7 +5,8 @@
 
 from ...utils import verbose
 from ...fixes import partial
-from ..utils import has_dataset, _data_path, _doc
+from ..utils import (has_dataset, _data_path, _data_path_doc,
+                     _get_version, _version_doc)
 
 
 has_sample_data = partial(has_dataset, name='sample')
@@ -18,5 +19,11 @@ def data_path(path=None, force_update=False, update_path=True, download=True,
                       update_path=update_path, name='sample',
                       download=download)
 
-data_path.__doc__ = _doc.format(name='sample',
-                                conf='MNE_DATASETS_SAMPLE_PATH')
+data_path.__doc__ = _data_path_doc.format(name='sample',
+                                          conf='MNE_DATASETS_SAMPLE_PATH')
+
+
+def get_version():
+    return _get_version('sample')
+
+get_version.__doc__ = _version_doc.format(name='sample')
diff --git a/mne/datasets/somato/__init__.py b/mne/datasets/somato/__init__.py
index ab144bc9d..aa3f82d8d 100644
--- a/mne/datasets/somato/__init__.py
+++ b/mne/datasets/somato/__init__.py
@@ -1,4 +1,4 @@
 """Somatosensory dataset
 """
 
-from .somato import data_path, has_somato_data
+from .somato import data_path, has_somato_data, get_version
diff --git a/mne/datasets/somato/somato.py b/mne/datasets/somato/somato.py
index 525f2af3d..d0daf987b 100644
--- a/mne/datasets/somato/somato.py
+++ b/mne/datasets/somato/somato.py
@@ -1,11 +1,12 @@
-# Authors: Alexandre Gramfort <gramfort@nmr.mgh.harvard.edu>
+# Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
 #          Martin Luessi <mluessi@nmr.mgh.harvard.edu>
 #          Eric Larson <larson.eric.d@gmail.com>
 # License: BSD Style.
 
 from ...utils import verbose
 from ...fixes import partial
-from ..utils import has_dataset, _data_path, _doc
+from ..utils import (has_dataset, _data_path, _data_path_doc,
+                     _get_version, _version_doc)
 
 
 has_somato_data = partial(has_dataset, name='somato')
@@ -18,5 +19,11 @@ def data_path(path=None, force_update=False, update_path=True, download=True,
                       update_path=update_path, name='somato',
                       download=download)
 
-data_path.__doc__ = _doc.format(name='somato',
-                                conf='MNE_DATASETS_SOMATO_PATH')
+data_path.__doc__ = _data_path_doc.format(name='somato',
+                                          conf='MNE_DATASETS_SOMATO_PATH')
+
+
+def get_version():
+    return _get_version('somato')
+
+get_version.__doc__ = _version_doc.format(name='somato')
diff --git a/mne/datasets/spm_face/__init__.py b/mne/datasets/spm_face/__init__.py
index 43b513e9f..90f01c728 100644
--- a/mne/datasets/spm_face/__init__.py
+++ b/mne/datasets/spm_face/__init__.py
@@ -1,4 +1,4 @@
 """SPM face dataset
 """
 
-from .spm_data import data_path, has_spm_data
+from .spm_data import data_path, has_spm_data, get_version
diff --git a/mne/datasets/spm_face/spm_data.py b/mne/datasets/spm_face/spm_data.py
index ca681de16..19c6461ee 100644
--- a/mne/datasets/spm_face/spm_data.py
+++ b/mne/datasets/spm_face/spm_data.py
@@ -4,7 +4,8 @@
 
 from ...utils import verbose
 from ...fixes import partial
-from ..utils import has_dataset, _data_path, _doc
+from ..utils import (has_dataset, _data_path, _data_path_doc,
+                     _get_version, _version_doc)
 
 
 has_spm_data = partial(has_dataset, name='spm')
@@ -17,5 +18,11 @@ def data_path(path=None, force_update=False, update_path=True, download=True,
                       update_path=update_path, name='spm',
                       download=download)
 
-data_path.__doc__ = _doc.format(name='spm',
-                                conf='MNE_DATASETS_SPM_DATA_PATH')
+data_path.__doc__ = _data_path_doc.format(name='spm',
+                                          conf='MNE_DATASETS_SPM_DATA_PATH')
+
+
+def get_version():
+    return _get_version('spm')
+
+get_version.__doc__ = _version_doc.format(name='spm')
diff --git a/mne/datasets/utils.py b/mne/datasets/utils.py
index 3ede4d718..be6f5fb0d 100644
--- a/mne/datasets/utils.py
+++ b/mne/datasets/utils.py
@@ -17,7 +17,7 @@ from ..externals.six import string_types
 from ..externals.six.moves import input
 
 
-_doc = """Get path to local copy of {name} dataset
+_data_path_doc = """Get path to local copy of {name} dataset
 
     Parameters
     ----------
@@ -49,6 +49,16 @@ _doc = """Get path to local copy of {name} dataset
 """
 
 
+_version_doc = """Get version of the local {name} dataset
+
+    Returns
+    -------
+    version : str | None
+        Version of the {name} local dataset, or None if the dataset
+        does not exist locally.
+"""
+
+
 def _dataset_version(path, name):
     """Get the version of the dataset"""
     ver_fname = op.join(path, 'version.txt')
@@ -64,7 +74,7 @@ def _dataset_version(path, name):
 
 
 def _data_path(path=None, force_update=False, update_path=True, download=True,
-               name=None, check_version=True):
+               name=None, check_version=False, return_version=False):
     """Aux function
     """
     key = {'sample': 'MNE_DATASETS_SAMPLE_PATH',
@@ -229,8 +239,14 @@ def _data_path(path=None, force_update=False, update_path=True, download=True,
                  'you may need to update the {name} dataset by using '
                  'mne.datasets.{name}.data_path(force_update=True)'.format(
                      name=name, current=data_version, newest=mne_version))
+    return (path, data_version) if return_version else path
+
 
-    return path
+def _get_version(name):
+    """Helper to get a dataset version"""
+    if not has_dataset(name):
+        return None
+    return _data_path(name=name, return_version=True)[1]
 
 
 def has_dataset(name):
diff --git a/mne/io/base.py b/mne/io/base.py
index 501e8a7f1..cb3623324 100644
--- a/mne/io/base.py
+++ b/mne/io/base.py
@@ -1054,6 +1054,7 @@ class _BaseRaw(ProjMixin, ContainsMixin, PickDropChannelsMixin,
         block : bool
             Whether to halt program execution until the figure is closed.
             Useful for setting bad channels on the fly (click on line).
+            May not work on all systems / platforms.
         highpass : float | None
             Highpass to apply when displaying data.
         lowpass : float | None
diff --git a/mne/viz/raw.py b/mne/viz/raw.py
index 518280032..1bea5a1f4 100644
--- a/mne/viz/raw.py
+++ b/mne/viz/raw.py
@@ -373,6 +373,7 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=None,
     block : bool
         Whether to halt program execution until the figure is closed.
         Useful for setting bad channels on the fly by clicking on a line.
+        May not work on all systems / platforms.
     highpass : float | None
         Highpass to apply when displaying data.
     lowpass : float | None
@@ -623,7 +624,10 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=None,
         _toggle_options(None, params)
 
     if show:
-        plt.show(block=block)
+        try:
+            plt.show(block=block)
+        except TypeError:  # not all versions have this
+            plt.show()
 
     return fig
 
diff --git a/setup.py b/setup.py
index 9cbd8af53..353d7c37d 100755
--- a/setup.py
+++ b/setup.py
@@ -71,6 +71,7 @@ if __name__ == "__main__":
                     'mne.datasets.somato',
                     'mne.datasets.spm_face',
                     'mne.datasets.testing',
+                    'mne.datasets.tests',
                     'mne.externals',
                     'mne.io', 'mne.io.tests',
                     'mne.io.array', 'mne.io.array.tests',


Test patch:
diff --git a/mne/datasets/testing/__init__.py b/mne/datasets/testing/__init__.py
index 816bbf18a..7fa74ee41 100644
--- a/mne/datasets/testing/__init__.py
+++ b/mne/datasets/testing/__init__.py
@@ -1,4 +1,4 @@
 """MNE sample dataset
 """
 
-from ._testing import data_path, requires_testing_data
+from ._testing import data_path, requires_testing_data, get_version
diff --git a/mne/datasets/testing/_testing.py b/mne/datasets/testing/_testing.py
index fe23cf4fb..932bd2e20 100644
--- a/mne/datasets/testing/_testing.py
+++ b/mne/datasets/testing/_testing.py
@@ -7,7 +7,8 @@ import numpy as np
 
 from ...utils import verbose, get_config
 from ...fixes import partial
-from ..utils import has_dataset, _data_path, _doc
+from ..utils import (has_dataset, _data_path, _data_path_doc,
+                     _get_version, _version_doc)
 
 
 has_testing_data = partial(has_dataset, name='testing')
@@ -24,8 +25,14 @@ def data_path(path=None, force_update=False, update_path=True,
                       update_path=update_path, name='testing',
                       download=download)
 
-data_path.__doc__ = _doc.format(name='testing',
-                                conf='MNE_DATASETS_TESTING_PATH')
+data_path.__doc__ = _data_path_doc.format(name='testing',
+                                          conf='MNE_DATASETS_TESTING_PATH')
+
+
+def get_version():
+    return _get_version('testing')
+
+get_version.__doc__ = _version_doc.format(name='testing')
 
 
 # Allow forcing of testing dataset skip (for Debian tests) using:
diff --git a/mne/datasets/tests/__init__.py b/mne/datasets/tests/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/mne/datasets/tests/test_datasets.py b/mne/datasets/tests/test_datasets.py
new file mode 100644
index 000000000..76bacaa14
--- /dev/null
+++ b/mne/datasets/tests/test_datasets.py
@@ -0,0 +1,15 @@
+from nose.tools import assert_true
+
+from mne import datasets
+from mne.externals.six import string_types
+
+
+def test_datasets():
+    """Test simple dataset functions
+    """
+    for dname in ('sample', 'somato', 'spm_face', 'testing'):
+        dataset = getattr(datasets, dname)
+    if dataset.data_path(download=False) != '':
+        assert_true(isinstance(dataset.get_version(), string_types))
+    else:
+        assert_true(dataset.get_version() is None)