Repository: mne-tools/mne-python

Issue:
Evoked topography ylim
The suggested format for kwarg `ylim` in the documentation generates a TypeError.
after making the following changes to this [example](http://martinos.org/mne/stable/auto_examples/plot_topo_compare_conditions.html) script:

``` python
# Set up amplitude-peak rejection values for EEG channels
reject = dict(eeg=150e-6)
# pick EEG channels
picks = mne.pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False,
                       include=include, exclude='bads')
# Show topography for two different conditions
plot_topo(evokeds, color=colors, title=title, ylim=dict(eeg=[-150e-6, 150e6]))
```

Evoked topography ylim
The suggested format for kwarg `ylim` in the documentation generates a TypeError.
after making the following changes to this [example](http://martinos.org/mne/stable/auto_examples/plot_topo_compare_conditions.html) script:

``` python
# Set up amplitude-peak rejection values for EEG channels
reject = dict(eeg=150e-6)
# pick EEG channels
picks = mne.pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False,
                       include=include, exclude='bads')
# Show topography for two different conditions
plot_topo(evokeds, color=colors, title=title, ylim=dict(eeg=[-150e-6, 150e6]))
```

Evoked topography ylim
The suggested format for kwarg `ylim` in the documentation generates a TypeError.
after making the following changes to this [example](http://martinos.org/mne/stable/auto_examples/plot_topo_compare_conditions.html) script:

``` python
# Set up amplitude-peak rejection values for EEG channels
reject = dict(eeg=150e-6)
# pick EEG channels
picks = mne.pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False,
                       include=include, exclude='bads')
# Show topography for two different conditions
plot_topo(evokeds, color=colors, title=title, ylim=dict(eeg=[-150e-6, 150e6]))
```



Discussion:
are you saying that this code creates an error?

yes, specifically `ylim=dict(eeg=[-150e-6, 150e6])` the other changes I made to get the eeg channels in the example script. 

problem reproduced

@dengemann it's bug in plot_topo. Some python magic with zip(\* ... around line 361 I suspect.

please have a look.

are you saying that this code creates an error?

yes, specifically `ylim=dict(eeg=[-150e-6, 150e6])` the other changes I made to get the eeg channels in the example script. 

problem reproduced

@dengemann it's bug in plot_topo. Some python magic with zip(\* ... around line 361 I suspect.

please have a look.

are you saying that this code creates an error?

yes, specifically `ylim=dict(eeg=[-150e-6, 150e6])` the other changes I made to get the eeg channels in the example script. 

problem reproduced

@dengemann it's bug in plot_topo. Some python magic with zip(\* ... around line 361 I suspect.

please have a look.


Resolving patch:
diff --git a/mne/viz/topo.py b/mne/viz/topo.py
--- a/mne/viz/topo.py
+++ b/mne/viz/topo.py
@@ -232,7 +232,7 @@ def _plot_timeseries(ax, ch_idx, tmin, tmax, vmin, vmax, ylim, data, color,
 
 def _check_vlim(vlim):
     """AUX function"""
-    return not np.isscalar(vlim) and not vlim is None
+    return not np.isscalar(vlim) and vlim is not None
 
 
 def plot_topo(evoked, layout=None, layout_scale=0.945, color=None,
@@ -358,7 +358,11 @@ def plot_topo(evoked, layout=None, layout_scale=0.945, color=None,
     elif isinstance(ylim, dict):
         ylim_ = _mutable_defaults(('ylim', ylim))[0]
         ylim_ = [ylim_[kk] for kk in types_used]
-        ylim_ = zip(*[np.array(yl) for yl in ylim_])
+        # extra unpack to avoid bug #1700
+        if len(ylim_) == 1:
+            ylim_ = ylim_[0]
+        else:
+            ylim_ = zip(*[np.array(yl) for yl in ylim_])
     else:
         raise ValueError('ylim must be None ore a dict')
 


Test patch: