Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def pytest_configure(config):
ignore:`np.MachAr` is deprecated.*:DeprecationWarning
# matplotlib 3.6 and pyvista/nilearn
ignore:.*cmap function will be deprecated.*:
# TODO: matplotlib 3.7 that needs to be fixed
ignore:The rectangles attribute was deprecated in Matplotlib.*:
ignore:The lines attribute was deprecated in Matplotlib.*:
# joblib hasn't updated to avoid distutils
ignore:.*distutils package is deprecated.*:DeprecationWarning
ignore:.*distutils Version classes are deprecated.*:DeprecationWarning
Expand Down
6 changes: 3 additions & 3 deletions mne/viz/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2359,8 +2359,8 @@ def _press(event, params):
params['fig'].canvas.draw()

def _update_timeslice(idx, params):
params['lx'].set_xdata(idx / params['stc'].sfreq +
params['stc'].tmin)
params['lx'].set_xdata([idx / params['stc'].sfreq +
params['stc'].tmin])
ax_x, ax_y, ax_z = params['ax_x'], params['ax_y'], params['ax_z']
plot_map_callback = params['plot_func']
# Crosshairs are the first thing plotted in stat_map, and the last
Expand Down Expand Up @@ -2406,7 +2406,7 @@ def _onclick(event, params, verbose=None):
if loc_idx is not None:
ax_time.lines[0].set_ydata(ydata)
else:
ax_time.lines[0].set_ydata(0.)
ax_time.lines[0].set_ydata([0.])
_update_vertlabel(loc_idx)
params['fig'].canvas.draw()

Expand Down
2 changes: 1 addition & 1 deletion mne/viz/_brain/_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ def plot_time_line(self, update=True):
lw=1,
update=update,
)
self.time_line.set_xdata(current_time)
self.time_line.set_xdata([current_time])
if update:
self.mpl_canvas.update_plot()

Expand Down
6 changes: 4 additions & 2 deletions mne/viz/_mpl_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ def _create_annotation_fig(self):
drag_ax.set_xlim(0, aspect)
drag_ax.set_axis_off()
# reposition & resize checkbox & label
# TODO: .rectangles deprecated in matplotlib 3.7
rect = checkbox.rectangles[0]
_pad, _size = (0.2, 0.6)
rect.set_bounds(_pad, _pad, _size, _size)
Expand Down Expand Up @@ -1396,6 +1397,7 @@ def _create_proj_fig(self):
# draw checkboxes
checkboxes = CheckButtons(ax, labels=labels, actives=self.mne.projs_on)
# gray-out already applied projectors
# TODO: lines and rectangles deprecated in matplotlib 3.7
for label, rect, lines in zip(checkboxes.labels,
checkboxes.rectangles,
checkboxes.lines):
Expand Down Expand Up @@ -1950,8 +1952,8 @@ def _show_vline(self, xdata):
rel_time = self._recompute_epochs_vlines(xdata)
xdata = rel_time + self.mne.inst.times[0]
else:
self.mne.vline.set_xdata(xdata)
self.mne.vline_hscroll.set_xdata(xdata)
self.mne.vline.set_xdata([xdata])
self.mne.vline_hscroll.set_xdata([xdata])
text = self._xtick_formatter(xdata, ax_type='vline')[:12]
self.mne.vline_text.set_text(text)
self._toggle_vline(True)
Expand Down
20 changes: 9 additions & 11 deletions mne/viz/backends/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#
# License: Simplified BSD

import sys
from colorsys import rgb_to_hls
from contextlib import nullcontext

Expand Down Expand Up @@ -62,8 +61,11 @@ def test_theme_colors(pg_backend, theme, monkeypatch, tmp_path):
monkeypatch.setattr(darkdetect, 'theme', lambda: 'light')
raw = RawArray(np.zeros((1, 1000)), create_info(1, 1000., 'eeg'))
_, api = _check_qt_version(return_api=True)
if api in ('PyQt6', 'PySide6') and theme == 'dark':
ctx = pytest.warns(RuntimeWarning, match='not yet supported')
if api in ('PyQt6', 'PySide6'):
if theme == 'dark': # we force darkdetect to say the sys is light
ctx = pytest.warns(RuntimeWarning, match='not yet supported')
else:
ctx = nullcontext()
return_early = True
else:
ctx = nullcontext()
Expand All @@ -74,14 +76,10 @@ def test_theme_colors(pg_backend, theme, monkeypatch, tmp_path):
return # we could add a ton of conditionals below, but KISS
is_dark = _qt_is_dark(fig)
# on Darwin these checks get complicated, so don't bother for now
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# on Darwin these checks get complicated, so don't bother for now

comment no longer relevant, you removed the if != Darwin line

if sys.platform != 'darwin':
if theme == 'dark':
assert is_dark, theme
elif theme == 'light':
assert not is_dark, theme
else:
got_dark = darkdetect.theme().lower() == 'dark'
assert is_dark is got_dark
if theme == 'dark':
assert is_dark, theme
elif theme == 'light':
assert not is_dark, theme

def assert_correct_darkness(widget, want_dark):
__tracebackhide__ = True # noqa
Expand Down
6 changes: 6 additions & 0 deletions mne/viz/tests/test_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
from mne import Epochs, create_info, EpochsArray
from mne.datasets import testing
from mne.event import make_fixed_length_events
from mne.utils import check_version
from mne.viz import plot_drop_log


_mpl_37 = check_version('matplotlib', '3.7')


def test_plot_epochs_not_preloaded(epochs_unloaded, browser_backend):
"""Test plotting non-preloaded epochs."""
assert epochs_unloaded._data is None
Expand Down Expand Up @@ -131,6 +135,8 @@ def test_plot_epochs_clicks(epochs, epochs_full, capsys,
fig = epochs_full.plot(n_epochs=3)
first_ch = fig._get_ticklabels('y')[0]
assert first_ch not in fig.mne.info['bads']
if _mpl_37 and browser_backend.name == 'matplotlib':
pytest.xfail(reason='KeyError on matplotlib 3.7')
fig._click_ch_name(ch_index=0, button=1) # click ch name to mark bad
assert first_ch in fig.mne.info['bads']
# test clicking scrollbars
Expand Down
18 changes: 17 additions & 1 deletion mne/viz/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
from mne.io import RawArray
from mne.io.pick import _DATA_CH_TYPES_ORDER_DEFAULT, _PICK_TYPES_DATA_DICT
from mne.utils import (_dt_to_stamp, _record_warnings, get_config, set_config,
_assert_no_instances)
_assert_no_instances, check_version)
from mne.viz import plot_raw, plot_sensors
from mne.viz.utils import _fake_click, _fake_keypress


# TODO: fix these matplotlib 3.7 compat bugs
_mpl_37 = check_version('matplotlib', '3.7')


def _annotation_helper(raw, browse_backend, events=False):
"""Test interactive annotations."""
ismpl = browse_backend.name == 'matplotlib'
Expand Down Expand Up @@ -310,6 +314,9 @@ def test_plot_raw_selection(raw, browser_backend):
# (QTest.mouseClick works isolated on all platforms but somehow
# not in this context. _fake_click isn't working on linux)
sel_fig._chkbx_changed(list(sel_fig.chkbxs.keys())[0])
# TODO: Results are wrong on matplotlib 3.7!
if browser_backend.name == 'matplotlib' and _mpl_37:
pytest.xfail('Fails on matplotlib 3.7')
assert len(fig.mne.traces) == len(sel_dict['Left-temporal']) # 6
assert not fig.mne.butterfly
# test clicking on "custom" when not defined: should be no-op
Expand Down Expand Up @@ -378,6 +385,9 @@ def test_plot_raw_ssp_interaction(raw, browser_backend):
assert _proj_status(ssp_fig, browser_backend) == [True, True, True]
# this should work (proj 1 not applied)
_proj_click(1, fig, browser_backend)
# TODO: Broken on matplotlib 3.7
if browser_backend.name == 'matplotlib' and _mpl_37:
pytest.xfail('Fails on matplotlib 3.7')
assert _proj_status(ssp_fig, browser_backend) == [True, False, True]
# turn it back on
_proj_click(1, fig, browser_backend)
Expand All @@ -397,6 +407,8 @@ def test_plot_raw_ssp_interaction(raw, browser_backend):

def test_plot_raw_child_figures(raw, browser_backend):
"""Test spawning and closing of child figures."""
if browser_backend.name == 'matplotlib' and _mpl_37:
pytest.xfail(reason='IndexError on matplotlib 3.7')
ismpl = browser_backend.name == 'matplotlib'
with raw.info._unlock():
raw.info['lowpass'] = 10. # allow heavy decim during plotting
Expand Down Expand Up @@ -434,6 +446,8 @@ def test_orphaned_annot_fig(raw, browser_backend):
"""Test that annotation window is not orphaned (GH #10454)."""
if browser_backend.name != 'matplotlib':
return
if _mpl_37:
pytest.xfail(reason='IndexError on matplotlib 3.7')
assert browser_backend._get_n_figs() == 0
fig = raw.plot()
_spawn_child_fig(fig, 'fig_annotation', browser_backend, 'a')
Expand Down Expand Up @@ -647,6 +661,8 @@ def test_plot_misc_auto(browser_backend):
@pytest.mark.slowtest
def test_plot_annotations(raw, browser_backend):
"""Test annotation mode of the plotter."""
if browser_backend.name == 'matplotlib' and _mpl_37:
pytest.xfail(reason='IndexError on matplotlib 3.7')
ismpl = browser_backend.name == 'matplotlib'
with raw.info._unlock():
raw.info['lowpass'] = 10.
Expand Down
5 changes: 5 additions & 0 deletions mne/viz/tests/test_topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
cov_fname = op.join(base_dir, 'test-cov.fif')


# TODO: This is a problem on Windows at least
@pytest.mark.xfail(
condition=check_version('matplotlib', '3.7'),
reason='Lines not visible',
)
@pytest.mark.parametrize('constrained_layout', (False, True))
def test_plot_topomap_interactive(constrained_layout):
"""Test interactive topomap projection plotting."""
Expand Down
1 change: 1 addition & 0 deletions mne/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ def _draw_proj_checkbox(event, params, draw_current_state=True):

proj_checks = widgets.CheckButtons(ax_temp, labels=labels, actives=actives)
# make edges around checkbox areas
# TODO: .rectangles deprecated in matplotlib 3.7
for rect in proj_checks.rectangles:
rect.set_edgecolor('0.5')
rect.set_linewidth(1.)
Expand Down
3 changes: 1 addition & 2 deletions tools/azure_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ elif [ "${TEST_MODE}" == "pip-pre" ]; then
# python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps --extra-index-url https://www.riverbankcomputing.com/pypi/simple PyQt6 PyQt6-sip PyQt6-Qt6
python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps PyQt6 PyQt6-sip PyQt6-Qt6
# SciPy Windows build is missing from conda nightly builds
python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" "matplotlib<3.7" # gh-11332
python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy scipy statsmodels pandas scikit-learn dipy
python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy scipy statsmodels pandas scikit-learn dipy matplotlib
python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps -f "https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com" h5py
python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps -i "https://test.pypi.org/simple" openmeeg
python -m pip install --progress-bar off --upgrade --pre --only-binary ":all:" --no-deps vtk
Expand Down
3 changes: 1 addition & 2 deletions tools/github_actions_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ else
# pip install $STD_ARGS --pre --only-binary ":all:" --no-deps --extra-index-url https://www.riverbankcomputing.com/pypi/simple PyQt6 PyQt6-sip PyQt6-Qt6
pip install $STD_ARGS --pre --only-binary ":all:" --no-deps PyQt6 PyQt6-sip PyQt6-Qt6
echo "NumPy/SciPy/pandas etc."
pip install $STD_ARGS --pre --only-binary ":all:" "matplotlib<3.7" # gh-11332
pip install $STD_ARGS --pre --only-binary ":all:" --no-deps --default-timeout=60 -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy scipy scikit-learn dipy pandas statsmodels
pip install $STD_ARGS --pre --only-binary ":all:" --no-deps --default-timeout=60 -i "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy scipy scikit-learn dipy pandas statsmodels matplotlib
pip install $STD_ARGS --pre --only-binary ":all:" --no-deps -f "https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com" h5py
pip install $STD_ARGS --pre --only-binary ":all:" pillow
# We don't install Numba here because it forces an old NumPy version
Expand Down