Repository: mne-tools/mne-python

Issue:
__repr__ for Epochs when read from disk
the **repr** of an Epochs objects read from disk is `_BaseRaw`. should this be `Epochs`? I guess we can't distinguish between Epochs and EpochsArray saved to disk and that is why the generic basename is being used.

cc: @Eric89GXL 



Discussion:
What we should really do is rename Epochs to something else (like
EpochsFromRaw but a less crappy a name) and change _BaseEpochs to Epochs,
but that will break people's code if they have subclassed. So I'm not sure
what a good solution is.

sorry, that was supposed to saw `_BaseEpochs`, not `_BaseRaw`. but actually, nvm. I just loaded epochs from disk and it says `Epochs` now. I think I am ok with how things are now without any changes

actually, i was wrong. i think it is still there.

Yeah, it should still be there. I don't have a good solution in mind. We could just make `BaseEpochs` public.

what do you think about doing this in the read_epochs:

``` python
epochs = _BaseEpochs(info, data, events, event_id, tmin, tmax,
                             baseline, name=name, on_missing='ignore',
                             verbose=verbose)
epochs.__class__.__name__ = 'Epochs'
```

BOOO HISSS monkey patch :) I think I'd actually prefer making `BaseEpochs` public instead.

hahaha, but then what would make people use `EpochsArray` instead of `BaseEpochs`, they look similar? or simply, what's the use of making it public other than the repr?

There isn't really a purpose. We can tell people they shouldn't instatiate it directly, and link to the other classes. To actually answer your question, EpochsArray has a few checks in it, otherwise it is a very thin wrapper around BaseEpochs.

I am lost. Can you paste a gist to reproduce the issue?

When you read any `-epo.fif` file and look at the `__repr__`, the class name is `<_BaseEpochs : ...>`


Resolving patch:
diff --git a/mne/epochs.py b/mne/epochs.py
--- a/mne/epochs.py
+++ b/mne/epochs.py
@@ -1165,7 +1165,10 @@ def __repr__(self):
             counts = ['%r: %i' % (k, sum(self.events[:, 2] == v))
                       for k, v in sorted(self.event_id.items())]
             s += ',\n %s' % ', '.join(counts)
-        return '<%s  |  %s>' % (self.__class__.__name__, s)
+        class_name = self.__class__.__name__
+        if class_name == '_BaseEpochs':
+            class_name = 'Epochs'
+        return '<%s  |  %s>' % (class_name, s)
 
     def _key_match(self, key):
         """Helper function for event dict use"""


Test patch:
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
@@ -417,6 +417,7 @@ def test_read_write_epochs():
     # test IO
     epochs.save(temp_fname)
     epochs_read = read_epochs(temp_fname)
+    assert_true(str(epochs_read).startswith('<Epochs'))
 
     assert_array_almost_equal(epochs_read.get_data(), epochs.get_data())
     assert_array_equal(epochs_read.times, epochs.times)
@@ -1506,6 +1507,7 @@ def test_array_epochs():
                    [1, 2] * 5]
     event_id = {'a': 1, 'b': 2}
     epochs = EpochsArray(data, info, events, tmin, event_id)
+    assert_true(str(epochs).startswith('<EpochsArray'))
     # From GH#1963
     assert_raises(ValueError, EpochsArray, data[:-1], info, events, tmin,
                   event_id)