internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mne-tools/mne-python

Issue:
Autoscale is not working properly in epochs.plot()
#### Describe the bug
Autoscale does not appear to work properly. It seems that scales are not calculated channel-type-wise. Probably related to https://github.com/mne-tools/mne-python/issues/5760.

#### Code to reproduce
```Python
import os.path as op
import mne

data_path = op.join(mne.datasets.sample.data_path(), 'MEG', 'sample')
raw = mne.io.read_raw_fif(
    op.join(data_path, 'sample_audvis_raw.fif'), preload=True)
raw.pick_types(eeg=True, meg=True)
raw.load_data().filter(None, 9, fir_design='firwin')
raw.set_eeg_reference('average', projection=True)  # set EEG average reference
event_id = {'auditory/left': 1, 'auditory/right': 2, 'visual/left': 3,
            'visual/right': 4, 'smiley': 5, 'button': 32}
events = mne.read_events(op.join(data_path, 'sample_audvis_raw-eve.fif'))
epochs = mne.Epochs(raw, events, event_id=event_id, tmin=-0.2, tmax=.5)

epochs.plot(scalings='auto')
```

#### Expected results
`epochs.plot(scalings=None)`
![autoscale_issue_scalingNone](https://user-images.githubusercontent.com/20129752/56743436-d8a4ed80-6776-11e9-9a15-3f9558bc5122.JPG)

#### Actual results
`epochs.plot(scalings='auto')`
![autoscale_issue](https://user-images.githubusercontent.com/20129752/56743499-f5d9bc00-6776-11e9-952b-0bfa60a4d200.JPG)

#### Additional information
Platform:      Windows-10-10.0.16299-SP0
Python:        3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)]
Executable:    C:\Continuum\anaconda3\pythonw.exe
CPU:           Intel64 Family 6 Model 142 Stepping 10, GenuineIntel: 8 cores
Memory:        15.9 GB

mne:           0.18.dev0
numpy:         1.16.2 {blas=mkl_rt, lapack=mkl_rt}
scipy:         1.2.1
matplotlib:    3.0.3 {backend=Qt5Agg}

sklearn:       0.20.3
nibabel:       Not found
mayavi:        Not found
cupy:          Not found
pandas:        0.24.2
dipy:          Not found



Discussion:
the "auto" explanation is not clear here
https://martinos.org/mne/stable/generated/mne.Epochs.html#mne.Epochs.plot
I agree that it should be done per channel type.

>

Just checked it. `mne.viz.utils._compute_scalings()` actually is doing the scaling per channel type. The bug seems to be somewhere else. 

Resolving patch:
diff --git a/mne/viz/utils.py b/mne/viz/utils.py
--- a/mne/viz/utils.py
+++ b/mne/viz/utils.py
@@ -1658,7 +1658,7 @@ def _compute_scalings(scalings, inst):
     else:
         data = inst._data
     if isinstance(inst, BaseEpochs):
-        data = inst._data.reshape([len(inst.ch_names), -1])
+        data = inst._data.swapaxes(0, 1).reshape([len(inst.ch_names), -1])
     # Iterate through ch types and update scaling if ' auto'
     for key, value in scalings.items():
         if value != 'auto':


Test patch:
Repository: mne-tools/mne-python

Issue:
tiny bug in title of AverageTFR.plot()
Titles always seem to end up with a right-parentheses at the end. 

![Screenshot_2019-05-07_15-03-45](https://user-images.githubusercontent.com/1810515/57338336-6d91da00-70d9-11e9-8a2c-32283effa6af.png)

Happens also with `AverageTFR.plot_joint()`

![Screenshot_2019-05-07_15-03-09](https://user-images.githubusercontent.com/1810515/57338327-64087200-70d9-11e9-9759-a38bdc0d1687.png)



Discussion:
Ugh. This possibly also affects other functions. You can assign me too, I'm probably to blame.
cool, it will be a race to see who needs to procrastinate first!

Resolving patch:
diff --git a/mne/time_frequency/tfr.py b/mne/time_frequency/tfr.py
--- a/mne/time_frequency/tfr.py
+++ b/mne/time_frequency/tfr.py
@@ -1252,7 +1252,7 @@ def _plot(self, picks=None, baseline=None, mode='mean', tmin=None,
                 tfr._onselect, cmap=cmap, source_plot_joint=source_plot_joint,
                 topomap_args={k: v for k, v in topomap_args.items()
                               if k not in {"vmin", "vmax", "cmap", "axes"}})
-            t_end = _imshow_tfr(
+            _imshow_tfr(
                 ax, 0, tmin, tmax, vmin, vmax, onselect_callback, ylim=None,
                 tfr=data[idx: idx + 1], freq=tfr.freqs, x_label='Time (s)',
                 y_label='Frequency (Hz)', colorbar=colorbar, cmap=cmap,
@@ -1261,11 +1261,11 @@ def _plot(self, picks=None, baseline=None, mode='mean', tmin=None,
 
             if title is None:
                 if combine is None or len(tfr.info['ch_names']) == 1:
-                    title = tfr.info['ch_names'][0] + t_end
+                    title = tfr.info['ch_names'][0]
                 else:
                     title = _set_title_multiple_electrodes(
                         title, combine, tfr.info["ch_names"], all=True,
-                        ch_type=ch_type) + t_end
+                        ch_type=ch_type)
 
             if title:
                 fig.suptitle(title)


Test patch:
Repository: mne-tools/mne-python

Issue:
4D/BTi import error if pdf/config channel orders to not match
#### Describe the bug
If the order of channels is different in the config and header (pdf) files, than the current match algorithm will report that they do not match even if all channels are present in both. 

#### Steps and/or code to reproduce
You need to have a config and header file with channels in a different order. If you do, then all you need to do is:

raw = mne.io.read_raw_bti(filename) 

#### Expected results
import the file

#### Actual results
throws a runtime exception

#### Additional information
Platform:      Darwin-18.2.0-x86_64-i386-64bit
Python:        3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37)  [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
Executable:    /Users/joshbear/bin/anaconda3/envs/mne/bin/python
CPU:           i386: 8 cores
Memory:        16.0 GB

mne:           0.17.0
numpy:         1.14.2 {blas=mkl_rt, lapack=mkl_rt}
scipy:         1.1.0
matplotlib:    2.2.2 {backend=MacOSX}

sklearn:       0.19.1
nibabel:       2.2.1
mayavi:        4.5.1.dev0 {qt_api=pyqt5, PyQt5=5.10.1}
cupy:          Not found
pandas:        0.23.0
dipy:          Not found



Discussion:

Resolving patch:
diff --git a/mne/io/bti/bti.py b/mne/io/bti/bti.py
--- a/mne/io/bti/bti.py
+++ b/mne/io/bti/bti.py
@@ -571,10 +571,10 @@ def _read_channel(fid):
                 'ymax': read_double(fid),
                 'index': read_int32(fid),
                 'checksum': read_int32(fid),
-                'off_flag': read_str(fid, 16),
+                'off_flag': read_str(fid, 4),
                 'offset': read_float(fid)})
 
-    fid.seek(12, 1)
+    fid.seek(24, 1)
 
     return out
 
@@ -627,7 +627,7 @@ def _read_process(fid):
             fid.seek(32, 1)
         elif ptype in BTI.PROC_BPFILTER:
             this_step['high_freq'] = read_float(fid)
-            this_step['low_frew'] = read_float(fid)
+            this_step['low_freq'] = read_float(fid)
         else:
             jump = this_step['user_space_size'] = read_int32(fid)
             fid.seek(32, 1)
@@ -825,6 +825,10 @@ def _read_bti_header(pdf_fname, config_fname, sort_by_ch_name=True):
         chans_cfg = [c for c in cfg['chs'] if c['chan_no']
                      in [c_['chan_no'] for c_ in chans]]
 
+        # sort chans_cfg and chans
+        chans = sorted(chans, key=lambda k: k['chan_no'])
+        chans_cfg = sorted(chans_cfg, key=lambda k: k['chan_no'])
+
         # check all pdf channels are present in config
         match = [c['chan_no'] for c in chans_cfg] == \
                 [c['chan_no'] for c in chans]


Test patch:
Repository: mne-tools/mne-python

Issue:
MAINT: iid=True in `cov.py` is deprecated
On latest `sklearn` master I get this in tests:
```
mne/cov.py:991: in _compute_covariance_auto
    gs.fit(data_[:, picks])
...
E           DeprecationWarning: The parameter 'iid' is deprecated in 0.22 and will be removed in 0.24.
```
Which is really from `cov.py` -- here showing where `gs` is instantiated and used:
```
            elif method_ == 'shrunk':
                ...
                gs = GridSearchCV(ShrunkCovariance(**mp),
                                  tuned_parameters, cv=cv, iid=True)
                for ch_type, picks in sub_picks_list:
                    gs.fit(data_[:, picks])
                    shrinkages.append((ch_type, gs.best_estimator_.shrinkage,
                                       picks))
```
I was hoping this would be an easy `**kwargs`-based-on-version fix, but it looks like `iid` is going away -- from the [sklearn docs](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html):
> iid : boolean, default=’warn’
>    If True, return the average score across folds, weighted by the number of samples in each test set. In this case, the data is assumed to be identically distributed across the folds, and the loss minimized is the total loss per sample, and not the mean loss across the folds. If False, return the average score across folds. Default is True, but will change to False in version 0.22, to correspond to the standard definition of cross-validation.
>    Changed in version 0.20: Parameter iid will change from True to False by default in version 0.22, and will be removed in 0.24.

@agramfort what do we do here? Is `iid=True` important, or is setting it to `iid=False` okay?


Discussion:
we should switch to iid=False

>


Resolving patch:
diff --git a/mne/cov.py b/mne/cov.py
--- a/mne/cov.py
+++ b/mne/cov.py
@@ -5,6 +5,7 @@
 # License: BSD (3-clause)
 
 from copy import deepcopy
+from distutils.version import LooseVersion
 import itertools as itt
 from math import log
 import os
@@ -898,6 +899,14 @@ def _eigvec_subspace(eig, eigvec, mask):
     return eig, eigvec
 
 
+def _get_iid_kwargs():
+    import sklearn
+    kwargs = dict()
+    if LooseVersion(sklearn.__version__) < LooseVersion('0.22'):
+        kwargs['iid'] = False
+    return kwargs
+
+
 def _compute_covariance_auto(data, method, info, method_params, cv,
                              scalings, n_jobs, stop_early, picks_list, rank):
     """Compute covariance auto mode."""
@@ -986,7 +995,7 @@ def _compute_covariance_auto(data, method, info, method_params, cv,
                 tuned_parameters = [{'shrinkage': shrinkage}]
                 shrinkages = []
                 gs = GridSearchCV(ShrunkCovariance(**mp),
-                                  tuned_parameters, cv=cv, iid=True)
+                                  tuned_parameters, cv=cv, **_get_iid_kwargs())
                 for ch_type, picks in sub_picks_list:
                     gs.fit(data_[:, picks])
                     shrinkages.append((ch_type, gs.best_estimator_.shrinkage,


Test patch:
Repository: mne-tools/mne-python

Issue:
Incorrect scaling on macOS HiDPI when resizing plot window
We've already fixed the incorrectly scaled `plot_raw` window on macOS on a HiDPI (retina) display in #6043 (discussion in #6034). However, the same issue occurs after resizing the `plot_raw` window. After resizing, the axes overlap again. Is there another place where we calculate the layout of this figure? Could other plots also be affected?


Discussion:
`git grep resize` shows (among other things):
```
mne/viz/raw.py:    callback_resize = partial(_helper_raw_resize, params=params)
```
Can you look?
`_helper_raw_resize` calls `_layout_figure`, which works on initialization but not on resize. It's hard to debug for me, because while debugging it doesn't even work on initialization...
@stfnrpplngr any ideas?
I cannot reproduce on my HiDPI OSX machine. Maybe it's a PyQt / `matplotlib` bug.
It only affects the `osx` backend - I don't have this issue with the `qt5` backend. @larsoner can you reproduce with `osx`?
I can't (currently at least) test it because I get the "ImportError: Python is not installed as a framework" error.
Matplotlib 3.1.0 should have fixed this issue: https://matplotlib.org/3.1.0/users/whats_new.html#matplotlib-no-longer-requires-framework-app-build-on-macosx-backend
Ahh okay I can try on Friday
... but also this seems like it's almost certainly a `mpl` problem, not an MNE one, since `Qt5Agg` works but `macOS` does not. Can we close here and you can open a MPL issue after making a minimal example (once I confirm I have the same problem later this week)?
Yes, I agree it should be a matplotlib issue. Can you help me make a minimal example?
You can try writing a few lines of code that will:

1. Create figure
2. Add subplot axes (using whatever `plt` interface we use in `raw.plot` under the hood)
3. Connect resize event handler
4. Show it works with Qt5 backend, fails with OSX backend

If step (4) does not work, then we must have some additional complexity in our code which breaks things, and we can instead try working from the "top down" (removing bits of our code until things work properly) instead of the "bottom up" (creating MPL code from scratch that works until we add something that breaks).

Resolving patch:
diff --git a/mne/viz/utils.py b/mne/viz/utils.py
--- a/mne/viz/utils.py
+++ b/mne/viz/utils.py
@@ -510,7 +510,9 @@ def _draw_proj_checkbox(event, params, draw_current_state=True):
 def _layout_figure(params):
     """Set figure layout. Shared with raw and epoch plots."""
     size = params['fig'].get_size_inches() * params['fig'].dpi
-    dpi_ratio = getattr(params["fig"].canvas, '_dpi_ratio', 1)
+    dpi_ratio = 1.
+    for key in ('_dpi_ratio', '_device_scale'):
+        dpi_ratio = getattr(params["fig"].canvas, key, dpi_ratio)
     size /= dpi_ratio  # account for HiDPI resolutions
 
     scroll_width = 25


Test patch:
Repository: mne-tools/mne-python

Issue:
Why do we have matplotlib < 3.1 in requirements.txt?
@massich can you try if 3.1 works? It would be nice to support the current matplotlib version.


Discussion:
I don't know why, will open a PR to revert to see what happens soon unless @massich chimes in

Resolving patch:
diff --git a/mne/conftest.py b/mne/conftest.py
--- a/mne/conftest.py
+++ b/mne/conftest.py
@@ -22,7 +22,6 @@
 import numpy as np
 import mne
 from mne.datasets import testing
-from mne.fixes import _get_args
 
 test_path = testing.data_path(download=False)
 s_path = op.join(test_path, 'MEG', 'sample')
@@ -81,9 +80,8 @@ def matplotlib_config():
     import matplotlib
     # "force" should not really be necessary but should not hurt
     kwargs = dict()
-    if 'warn' in _get_args(matplotlib.use):
-        kwargs['warn'] = False
-    matplotlib.use('agg', force=True, **kwargs)  # don't pop up windows
+    with warnings.catch_warnings(record=True):  # ignore warning
+        matplotlib.use('agg', force=True, **kwargs)  # don't pop up windows
     import matplotlib.pyplot as plt
     assert plt.get_backend() == 'agg'
     # overwrite some params that can horribly slow down tests that


Test patch:
Repository: mne-tools/mne-python

Issue:
How do I disable the Esc key from closing raw.plot?
In MNELAB, I would like my raw.plot window to not close if the user hits the Esc key. Previously, I used the following hack which worked for matplotlib < 3:

```
 try:
    key_events = fig.canvas.callbacks.callbacks["key_press_event"][8]
except KeyError:
    pass
else:  # this requires MNE >=0.15
    key_events.func.keywords["params"]["close_key"] = None
```

Of course this was bound to fail, and with matplotlib >= 3 `key_events` is now a `matplotlib.cbook._StrongRef` object, whereas previously it used to be a `matplotlib.cbook._BoundMethodProxy` object. Of course private methods can change at anytime, but does anyone know either how to make the old hack work again, or better yet how to modify/delete existing callbacks?


Discussion:
I wonder if we should just monkey patch to add an attribute to `fig` as `fig._mne_params = params`
Yes, why not? If this gives an interface where I can change/delete callbacks... But once a callback is set, would adding our params solve the issue? Isn't a matplotlib call necessary to change a callback? If so, which?
> Isn't a matplotlib call necessary to change a callback? If so, which?

It depends what you mean. If you mean removing or adding a callback function yes you have to use mpl. If you just want to make it so that the existing `mne` callback does nothing on `esc`, it should be enough to do `fig._mne_params['close_key'] = None`.

Resolving patch:
diff --git a/mne/viz/raw.py b/mne/viz/raw.py
--- a/mne/viz/raw.py
+++ b/mne/viz/raw.py
@@ -492,6 +492,16 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20,
     except TypeError:  # not all versions have this
         plt_show(show)
 
+    # add MNE params dict to the resulting figure object so that parameters can
+    # be modified after the figure has been created; this is useful e.g. to
+    # remove the keyboard shortcut to close the figure with the 'Esc' key,
+    # which can be done with
+    #
+    # fig._mne_params['close_key'] = None
+    #
+    # (assuming that the figure object is fig)
+    params['fig']._mne_params = params
+
     return params['fig']
 
 


Test patch:
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
@@ -186,6 +186,10 @@ def test_plot_raw():
     assert len(plt.get_fignums()) == 0
     fig = raw.plot(events=events, order=[1, 7, 3], group_by='original')
     assert len(plt.get_fignums()) == 1
+
+    # make sure fig._mne_params is present
+    assert isinstance(fig._mne_params, dict)
+
     # test mouse clicks
     x = fig.get_axes()[0].lines[1].get_xdata().mean()
     y = fig.get_axes()[0].lines[1].get_ydata().mean()
@@ -285,6 +289,7 @@ def test_plot_raw():
             break
     for key in ['down', 'up', 'escape']:
         fig.canvas.key_press_event(key)
+
     plt.close('all')
Repository: mne-tools/mne-python

Issue:
BUG: Arrow rendering no longer correct (scale issue?)
In 0.16 it looks good

https://mne-tools.github.io/0.16/auto_tutorials/plot_dipole_orientations.html#limiting-orientations-but-not-fixing-them

In 0.17+ the activity disappears for some reason (maybe meters vs mm in the arrow scales?)

https://13931-1301584-gh.circle-artifacts.com/0/dev/auto_tutorials/source-modeling/plot_dipole_orientations.html#limiting-orientations-but-not-fixing-them


Discussion:
@GuillaumeFavelier can you look into why it no longer plots?
Yeah sure, I'll take care of it.
**TL;DR**: I removed [this line](https://github.com/mne-tools/mne-python/blob/master/mne/viz/_3d.py#L2232) and it worked for me.

For reference, this bug occurs in [`plot_dipole_orientations.py`](https://github.com/mne-tools/mne-python/blob/master/tutorials/source-modeling/plot_dipole_orientations.py#L206-L207).

I investigated this one and I discovered that the bug is related to the `alpha` value passed to the `PySurfer` `Brain` object through [`add_data()`](https://github.com/mne-tools/mne-python/blob/master/mne/viz/_3d.py#L2224-L2231).

In my experiments, I saw that although `alpha` and `vector_alpha` are passed as different parameters (`alpha` for the opacity of the overlay and `vector_alpha` for the opacity of the arrows), `alpha` has also an influence on the glyphs displayed. For short, to display the glyphs, both `alpha` and `vector_alpha` must allow it with strictly positive values.

So it's possible to do:
```diff
brain_loose = stc.plot(subjects_dir=subjects_dir, initial_time=time_max,
- time_unit='s', size=(600, 400), overlay_alpha=0)
+ time_unit='s', size=(600, 400), overlay_alpha=0.5)
```
But this will activate the smoothing steps and the rendering will be slightly different.
What do you think @larsoner ?

Resolving patch:
diff --git a/mne/viz/_3d.py b/mne/viz/_3d.py
--- a/mne/viz/_3d.py
+++ b/mne/viz/_3d.py
@@ -2229,7 +2229,6 @@ def plot_vector_source_estimates(stc, subject=None, hemi='lh', colormap='hot',
                                scale_factor=scale_factor,
                                min=scale_pts[0], max=scale_pts[2],
                                **ad_kwargs)
-    if 'mid' not in ad_kwargs:  # PySurfer < 0.9
         brain.scale_data_colormap(fmin=scale_pts[0], fmid=scale_pts[1],
                                   fmax=scale_pts[2], **sd_kwargs)
 


Test patch:
Repository: mne-tools/mne-python

Issue:
x axis labels of epochs.plot() should be int, not float
Plotting epochs with `epochs.plot()` currently labels the overview bar on the x axis with floats, e.g. 1.0, 18.0, 35.0, etc. These labels refer to the epoch number so they should be ints.


Discussion:

Resolving patch:
diff --git a/mne/viz/epochs.py b/mne/viz/epochs.py
--- a/mne/viz/epochs.py
+++ b/mne/viz/epochs.py
@@ -1092,7 +1092,7 @@ def _prepare_mne_browse_epochs(params, projs, n_channels, n_epochs, scalings,
     hticks = list()
     for tick in hscroll_ticks:
         hticks.append(epoch_times.flat[np.abs(epoch_times - tick).argmin()])
-    hlabels = [x / n_times + 1 for x in hticks]
+    hlabels = [x // n_times + 1 for x in hticks]
     ax_hscroll.set_xticks(hticks)
     ax_hscroll.set_xticklabels(hlabels)
 


Test patch:
Repository: mne-tools/mne-python

Issue:
Issue with unknown unit (114 (FIFF_UNIT_CEL))
While playing with mne-bids in https://github.com/mne-tools/mne-bids/pull/219 I wanted to (re)set some channel names and stumbled over a potential bug with a BrainVision test file shipped with MNE and The FIFF unit "CEL":

https://github.com/mne-tools/mne-python/blob/b9b2c6884dc663ef42338bdccc9e7838820b29b3/mne/io/constants.py#L758

# How to reproduce
```Python
import os.path as op
import mne

# Assuming a dev installation of MNE
base_path = op.join(op.dirname(mne.__file__), 'io')
data_path = op.join(base_path, 'brainvision', 'tests', 'data')
raw_fname = op.join(data_path, 'test.vhdr')

# Read the data
raw = mne.io.read_raw_brainvision(raw_fname)

# Check channel "ReRef"
print('Name:"{}", type:"{}"'.format(raw.info['chs'][-1]['ch_name'],raw.info['chs'][-1]['kind']))
# Name:"ReRef", type:"502 (FIFFV_MISC_CH)"


# Set channel types ... do not change anything, just reset to same type it was before
raw.set_channel_types({'ReRef': 'misc'})

```

# Error message

> ValueError: Channel 'ReRef' has unknown unit (114 (FIFF_UNIT_CEL)). Please fix the measurement info of your data.

# Fix:

add `FIFF.FIFF_UNIT_CEL: 'C'` to these lines in `channels.py`:

https://github.com/mne-tools/mne-python/blob/b9b2c6884dc663ef42338bdccc9e7838820b29b3/mne/channels/channels.py#L199-L203


If this is a valid fix, I am happy to open a PR. Else: What's wrong?


Discussion:

Resolving patch:
diff --git a/mne/channels/channels.py b/mne/channels/channels.py
--- a/mne/channels/channels.py
+++ b/mne/channels/channels.py
@@ -200,7 +200,8 @@ def compensation_grade(self):
                FIFF.FIFF_UNIT_T: 'T',
                FIFF.FIFF_UNIT_T_M: 'T/m',
                FIFF.FIFF_UNIT_MOL: 'M',
-               FIFF.FIFF_UNIT_NONE: 'NA'}
+               FIFF.FIFF_UNIT_NONE: 'NA',
+               FIFF.FIFF_UNIT_CEL: 'C'}
 
 
 def _check_set(ch, projs, ch_type):


Test patch:
Repository: mne-tools/mne-python

Issue:
BUG: Example taking too much memory
@drammock CircleCI keeps spuriously failing here:

https://circleci.com/gh/mne-tools/mne-python/14240

That example probably uses too much memory, can you check?


Discussion:
Yep, I noticed that last night. It's first on my TODO list today.

On July 11, 2019 8:03:49 AM AKDT, Eric Larson <notifications@github.com> wrote:
>@drammock CircleCI keeps spuriously failing here:
>
>https://circleci.com/gh/mne-tools/mne-python/14240
>
>That example probably uses too much memory, can you check?


Resolving patch:
diff --git a/tutorials/epochs/plot_visualize_epochs.py b/tutorials/epochs/plot_visualize_epochs.py
--- a/tutorials/epochs/plot_visualize_epochs.py
+++ b/tutorials/epochs/plot_visualize_epochs.py
@@ -19,7 +19,9 @@
 event_id = {'auditory/left': 1, 'auditory/right': 2, 'visual/left': 3,
             'visual/right': 4, 'smiley': 5, 'button': 32}
 events = mne.read_events(op.join(data_path, 'sample_audvis_raw-eve.fif'))
-epochs = mne.Epochs(raw, events, event_id=event_id, tmin=-0.2, tmax=.5)
+epochs = mne.Epochs(raw, events, event_id=event_id, tmin=-0.2, tmax=.5,
+                    preload=True)
+del raw
 
 ###############################################################################
 # This tutorial focuses on visualization of epoched data. All of the functions


Test patch: