Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Post-release deprecations #13040

Merged
merged 14 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
4 changes: 1 addition & 3 deletions mne/channels/montage.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ def __repr__(self):
def plot(
self,
*,
scale=None,
scale_factor=None,
scale=1.0,
show_names=True,
kind="topomap",
show=True,
Expand All @@ -373,7 +372,6 @@ def plot(
return plot_montage(
self,
scale=scale,
scale_factor=scale_factor,
show_names=show_names,
kind=kind,
show=show,
Expand Down
19 changes: 5 additions & 14 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
_pl,
_record_warnings,
_TempDir,
check_version,
numerics,
)

Expand Down Expand Up @@ -636,21 +637,13 @@ def _use_backend(backend_name, interactive):

def _check_skip_backend(name):
from mne.viz.backends._utils import _notebook_vtk_works
from mne.viz.backends.tests._utils import (
has_imageio_ffmpeg,
has_pyvista,
has_pyvistaqt,
)

if not has_pyvista():
pytest.skip("Test skipped, requires pyvista.")
if not has_imageio_ffmpeg():
pytest.skip("Test skipped, requires imageio-ffmpeg")
pytest.importorskip("pyvista")
pytest.importorskip("imageio_ffmpeg")
if name == "pyvistaqt":
pytest.importorskip("pyvistaqt")
if not _check_qt_version():
pytest.skip("Test skipped, requires Qt.")
if not has_pyvistaqt():
pytest.skip("Test skipped, requires pyvistaqt")
else:
assert name == "notebook", name
if not _notebook_vtk_works():
Expand All @@ -660,10 +653,8 @@ def _check_skip_backend(name):
@pytest.fixture(scope="session")
def pixel_ratio():
"""Get the pixel ratio."""
from mne.viz.backends.tests._utils import has_pyvista

# _check_qt_version will init an app for us, so no need for us to do it
if not has_pyvista() or not _check_qt_version():
if not check_version("pyvista", "0.32") or not _check_qt_version():
return 1.0
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QMainWindow
Expand Down
26 changes: 3 additions & 23 deletions mne/datasets/eegbci/eegbci.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from os import path as op
from pathlib import Path

from ...utils import _url_to_local_path, logger, verbose, warn
from ...utils import _url_to_local_path, logger, verbose
from ..utils import _do_path_update, _downloader_params, _get_path, _log_time_size

EEGMI_URL = "https://physionet.org/files/eegmmidb/1.0.0/"
Expand Down Expand Up @@ -94,10 +94,9 @@ def data_path(url, path=None, force_update=False, update_path=None, *, verbose=N

@verbose
def load_data(
subjects=None,
runs=None,
subjects,
runs,
*,
subject=None,
path=None,
force_update=False,
update_path=None,
Expand All @@ -117,9 +116,6 @@ def load_data(
The subjects to use. Can be in the range of 1-109 (inclusive).
runs : int | list of int
The runs to use (see Notes for details).
subject : int
This parameter is deprecated and will be removed in mne version 1.9.
Please use ``subjects`` instead.
path : None | path-like
Location of where to look for the EEGBCI data. If ``None``, the environment
variable or config parameter ``MNE_DATASETS_EEGBCI_PATH`` is used. If neither
Expand Down Expand Up @@ -170,22 +166,6 @@ def load_data(
"""
import pooch

# XXX: Remove this with mne 1.9 ↓↓↓
# Also remove the subject parameter at that point.
# Also remove the `None` default for subjects and runs params at that point.
if subject is not None:
subjects = subject
warn(
"The ``subject`` parameter is deprecated and will be removed in version "
"1.9. Use the ``subjects`` parameter (note the `s`) to suppress this "
"warning.",
FutureWarning,
)
del subject
if subjects is None or runs is None:
raise ValueError("You must pass the parameters ``subjects`` and ``runs``.")
# ↑↑↑

t0 = time.time()

if not hasattr(subjects, "__iter__"):
Expand Down
12 changes: 0 additions & 12 deletions mne/datasets/eegbci/tests/test_eegbci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

import pytest

from mne.datasets import eegbci

Expand All @@ -14,14 +13,3 @@ def test_eegbci_download(tmp_path, fake_retrieve):
fnames = eegbci.load_data(subj, runs=[3], path=tmp_path, update_path=False)
assert len(fnames) == 1, subj
assert fake_retrieve.call_count == 4

# XXX: remove in version 1.9
with pytest.warns(FutureWarning, match="The ``subject``"):
fnames = eegbci.load_data(
subject=subjects, runs=[3], path=tmp_path, update_path=False
)
assert len(fnames) == 4

# XXX: remove in version 1.9
with pytest.raises(ValueError, match="You must pass the parameters"):
fnames = eegbci.load_data(path=tmp_path, update_path=False)
13 changes: 0 additions & 13 deletions mne/decoding/csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
_verbose_safe_false,
fill_doc,
pinv,
warn,
)


Expand Down Expand Up @@ -304,7 +303,6 @@ def plot_patterns(
info,
components=None,
*,
average=None,
ch_type=None,
scalings=None,
sensors=True,
Expand Down Expand Up @@ -342,7 +340,6 @@ def plot_patterns(
:func:`mne.create_info`.
components : float | array of float | None
The patterns to plot. If ``None``, all components will be shown.
%(average_plot_evoked_topomap)s
%(ch_type_topomap)s
scalings : dict | float | None
The scalings of the channel types to be applied for plotting.
Expand Down Expand Up @@ -391,9 +388,6 @@ def plot_patterns(
if components is None:
components = np.arange(self.n_components)

if average is not None:
warn("`average` is deprecated and will be removed in 1.10.", FutureWarning)

# set sampling frequency to have 1 component per time point
info = cp.deepcopy(info)
with info._unlock():
Expand All @@ -403,7 +397,6 @@ def plot_patterns(
# the call plot_topomap
fig = patterns.plot_topomap(
times=components,
average=average,
ch_type=ch_type,
scalings=scalings,
sensors=sensors,
Expand Down Expand Up @@ -438,7 +431,6 @@ def plot_filters(
info,
components=None,
*,
average=None,
ch_type=None,
scalings=None,
sensors=True,
Expand Down Expand Up @@ -476,7 +468,6 @@ def plot_filters(
:func:`mne.create_info`.
components : float | array of float | None
The patterns to plot. If ``None``, all components will be shown.
%(average_plot_evoked_topomap)s
%(ch_type_topomap)s
scalings : dict | float | None
The scalings of the channel types to be applied for plotting.
Expand Down Expand Up @@ -525,9 +516,6 @@ def plot_filters(
if components is None:
components = np.arange(self.n_components)

if average is not None:
warn("`average` is deprecated and will be removed in 1.10.", FutureWarning)

# set sampling frequency to have 1 component per time point
info = cp.deepcopy(info)
with info._unlock():
Expand All @@ -537,7 +525,6 @@ def plot_filters(
# the call plot_topomap
fig = filters.plot_topomap(
times=components,
average=average,
ch_type=ch_type,
scalings=scalings,
sensors=sensors,
Expand Down
2 changes: 1 addition & 1 deletion mne/decoding/ems.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def compute_ems(
data[:, this_picks] /= np.std(data[:, this_picks])

# Setup cross-validation. Need to use _set_cv to deal with sklearn
# deprecation of cv objects.
# changes in cv object handling.
y = epochs.events[:, 2]
_, cv_splits = _set_cv(cv, "classifier", X=y, y=y)

Expand Down
2 changes: 1 addition & 1 deletion mne/decoding/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_get_coef_multiclass(n_features, n_targets):
],
)
# TODO: Need to fix this properly in LinearModel
@pytest.mark.filterwarnings("ignore:'multi_class' was deprecated in.*:FutureWarning")
@pytest.mark.filterwarnings("ignore:'multi_class' was depr.*:FutureWarning")
@pytest.mark.filterwarnings("ignore:lbfgs failed to converge.*:")
def test_get_coef_multiclass_full(n_classes, n_channels, n_times):
"""Test a full example with pattern extraction."""
Expand Down
8 changes: 2 additions & 6 deletions mne/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
from math import log

import numpy as np
from packaging.version import parse

###############################################################################
# distutils

# distutils has been deprecated since Python 3.10 and was removed
# from the standard library with the release of Python 3.12.
# distutils LooseVersion removed in Python 3.12


def _compare_version(version_a, operator, version_b):
Expand All @@ -48,8 +46,6 @@ def _compare_version(version_a, operator, version_b):
bool
The result of the version comparison.
"""
from packaging.version import parse

mapping = {"<": "lt", "<=": "le", "==": "eq", "!=": "ne", ">=": "ge", ">": "gt"}
with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore")
Expand Down
19 changes: 1 addition & 18 deletions mne/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3187,7 +3187,7 @@ def concatenate_raws(


@fill_doc
def match_channel_orders(insts=None, copy=True, *, raws=None):
def match_channel_orders(insts, copy=True):
"""Ensure consistent channel order across instances (Raw, Epochs, or Evoked).

Parameters
Expand All @@ -3196,30 +3196,13 @@ def match_channel_orders(insts=None, copy=True, *, raws=None):
List of :class:`~mne.io.Raw`, :class:`~mne.Epochs`,
or :class:`~mne.Evoked` instances to order.
%(copy_df)s
raws : list
This parameter is deprecated and will be removed in mne version 1.9.
Please use ``insts`` instead.

Returns
-------
list of Raw | list of Epochs | list of Evoked
List of instances (Raw, Epochs, or Evoked) with channel orders matched
according to the order they had in the first item in the ``insts`` list.
"""
# XXX: remove "raws" parameter and logic below with MNE version 1.9
# and remove default parameter value of insts
if raws is not None:
warn(
"The ``raws`` parameter is deprecated and will be removed in version "
"1.9. Use the ``insts`` parameter to suppress this warning.",
DeprecationWarning,
)
insts = raws
elif insts is None:
# both insts and raws is None
raise ValueError(
"You need to pass a list of Raw, Epochs, or Evoked to ``insts``."
)
insts = deepcopy(insts) if copy else insts
ch_order = insts[0].ch_names
for inst in insts[1:]:
Expand Down
3 changes: 0 additions & 3 deletions mne/io/egi/tests/test_egi.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
egi_pause_w1337_events = None
egi_pause_w1337_skips = [(21956000.0, 40444000.0), (60936000.0, 89332000.0)]

# TODO: Remove once complete deprecation / FutureWarning about events_as_annonations
pytestmark = pytest.mark.filterwarnings("ignore:.*events_as_annotation.*:FutureWarning")


@requires_testing_data
@pytest.mark.parametrize(
Expand Down
8 changes: 0 additions & 8 deletions mne/io/fiff/tests/test_raw_fiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,6 @@ def test_concatenate_raws_order():
match_channel_orders(insts=raws, copy=True)
raw_concat = concatenate_raws(raws)

# XXX: remove in version 1.9
with pytest.warns(DeprecationWarning, match="``raws`` parameter is deprecated"):
match_channel_orders(raws=raws)

# XXX: remove in version 1.9
with pytest.raises(ValueError, match="need to pass a list"):
match_channel_orders()

# Now passes because all raws have the same order
match_channel_orders(insts=raws, copy=False)
raw_concat = concatenate_raws(raws)
Expand Down
2 changes: 1 addition & 1 deletion mne/io/neuralynx/neuralynx.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def read_raw_neuralynx(
)


# Helper for neo deprecation of exclude_filename -> exclude_filenames in 0.13.2
# Helper for neo change of exclude_filename -> exclude_filenames in 0.13.2
def _exclude_kwarg(exclude_fnames):
from neo.io import NeuralynxIO

Expand Down
16 changes: 0 additions & 16 deletions mne/source_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3918,22 +3918,6 @@ def stc_near_sensors(
_validate_type(src, (None, SourceSpaces), "src")
_check_option("mode", mode, ("sum", "single", "nearest", "weighted"))
if surface == "auto":
if src is not None:
pial_fname = op.join(subjects_dir, subject, "surf", "lh.pial")
pial_rr = read_surface(pial_fname)[0]
src_surf_is_pial = (
op.isfile(pial_fname)
and src[0]["rr"].shape == pial_rr.shape
and np.allclose(src[0]["rr"], pial_rr)
)
if not src_surf_is_pial:
warn(
"In version 1.8, ``surface='auto'`` will be the default "
"which will use the surface in ``src`` instead of the "
"pial surface when ``src != None``. Pass ``surface='pial'`` "
"or ``surface=None`` to suppress this warning",
DeprecationWarning,
)
surface = "pial" if src is None or src.kind == "surface" else None

# create a copy of Evoked using ecog, seeg and dbs
Expand Down
3 changes: 1 addition & 2 deletions mne/tests/test_source_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1711,8 +1711,7 @@ def test_stc_near_sensors(tmp_path):
for s in src:
transform_surface_to(s, "head", trans, copy=False)
assert src[0]["coord_frame"] == FIFF.FIFFV_COORD_HEAD
with pytest.warns(DeprecationWarning, match="instead of the pial"):
stc_src = stc_near_sensors(evoked, src=src, **kwargs)
stc_src = stc_near_sensors(evoked, src=src, **kwargs)
assert len(stc_src.data) == 7928
with pytest.warns(RuntimeWarning, match="not included"): # some removed
stc_src_full = compute_source_morph(
Expand Down
Loading
Loading