Skip to content

Commit

Permalink
MAINT: Post-release deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Dec 19, 2024
1 parent 05bd738 commit 63ec69e
Show file tree
Hide file tree
Showing 26 changed files with 36 additions and 241 deletions.
17 changes: 5 additions & 12 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,15 @@ 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,
)
from mne.viz.backends.tests._utils import has_imageio_ffmpeg

if not has_pyvista():
pytest.skip("Test skipped, requires pyvista.")
pytest.importorskip("pyvista")
if not has_imageio_ffmpeg():
pytest.skip("Test skipped, requires imageio-ffmpeg")
if name == "pyvistaqt":
if not _check_qt_version():
pytest.skip("Test skipped, requires Qt.")
if not has_pyvistaqt():
pytest.skip("Test skipped, requires pyvistaqt")
pytest.importorskip("pyvistaqt")
else:
assert name == "notebook", name
if not _notebook_vtk_works():
Expand All @@ -660,10 +655,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/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 @@ -525,9 +517,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 +526,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
50 changes: 0 additions & 50 deletions mne/time_frequency/tfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,9 +1187,6 @@ def __init__(
f'{classname} got unsupported parameter value{_pl(problem)} '
f'{" and ".join(problem)}.'
)
# shim for tfr_array_morlet deprecation warning (TODO: remove after 1.7 release)
if method == "morlet":
method_kw.setdefault("zero_mean", True)
# check method
valid_methods = ["morlet", "multitaper"]
if isinstance(inst, BaseEpochs):
Expand Down Expand Up @@ -2946,48 +2943,6 @@ class EpochsTFR(BaseTFR, GetEpochsMixin):
%(picks_good_data_noref)s
%(proj_psd)s
%(decim_tfr)s
%(events_epochstfr)s
.. deprecated:: 1.7
Pass an instance of :class:`~mne.Epochs` as ``inst`` instead, or use
:class:`~mne.time_frequency.EpochsTFRArray` which retains the old API.
%(event_id_epochstfr)s
.. deprecated:: 1.7
Pass an instance of :class:`~mne.Epochs` as ``inst`` instead, or use
:class:`~mne.time_frequency.EpochsTFRArray` which retains the old API.
selection : array
List of indices of selected events (not dropped or ignored etc.). For
example, if the original event array had 4 events and the second event
has been dropped, this attribute would be np.array([0, 2, 3]).
.. deprecated:: 1.7
Pass an instance of :class:`~mne.Epochs` as ``inst`` instead, or use
:class:`~mne.time_frequency.EpochsTFRArray` which retains the old API.
drop_log : tuple of tuple
A tuple of the same length as the event array used to initialize the
``EpochsTFR`` object. If the i-th original event is still part of the
selection, drop_log[i] will be an empty tuple; otherwise it will be
a tuple of the reasons the event is not longer in the selection, e.g.:
- ``'IGNORED'``
If it isn't part of the current subset defined by the user
- ``'NO_DATA'`` or ``'TOO_SHORT'``
If epoch didn't contain enough data names of channels that
exceeded the amplitude threshold
- ``'EQUALIZED_COUNTS'``
See :meth:`~mne.Epochs.equalize_event_counts`
- ``'USER'``
For user-defined reasons (see :meth:`~mne.Epochs.drop`).
.. deprecated:: 1.7
Pass an instance of :class:`~mne.Epochs` as ``inst`` instead, or use
:class:`~mne.time_frequency.EpochsTFRArray` which retains the old API.
%(metadata_epochstfr)s
.. deprecated:: 1.7
Pass an instance of :class:`~mne.Epochs` as ``inst`` instead, or use
:class:`~mne.time_frequency.EpochsTFRArray` which retains the old API.
%(n_jobs)s
%(verbose)s
%(method_kw_tfr)s
Expand Down Expand Up @@ -3031,11 +2986,6 @@ def __init__(
picks=None,
proj=False,
decim=1,
events=None,
event_id=None,
selection=None,
drop_log=None,
metadata=None,
n_jobs=None,
verbose=None,
**method_kw,
Expand Down
2 changes: 1 addition & 1 deletion mne/utils/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _sym_mat_pow(A, power, rcond=1e-7, reduce_rank=False, return_s=False):
return out


# SciPy deprecation of pinv + pinvh rcond (never worked properly anyway)
# SciPy pinv + pinvh rcond never worked properly anyway so we roll our own
def pinvh(a, rtol=None):
"""Compute a pseudo-inverse of a Hermitian matrix.
Expand Down
Loading

0 comments on commit 63ec69e

Please sign in to comment.