Skip to content

Commit

Permalink
MAINT: Post-release deprecations (#13040)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Dec 22, 2024
1 parent d814954 commit 637c231
Show file tree
Hide file tree
Showing 40 changed files with 112 additions and 312 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ repos:
language: python
entry: ./tools/hooks/sync_dependencies.py
files: pyproject.toml
additional_dependencies: ["mne"]
additional_dependencies: ["mne==1.9.0"]

# zizmor
- repo: https://github.com/woodruffw/zizmor-pre-commit
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The minimum required dependencies to run MNE-Python are:

.. ↓↓↓ BEGIN CORE DEPS LIST. DO NOT EDIT! HANDLED BY PRE-COMMIT HOOK ↓↓↓
- `Python <https://www.python.org>`__ ≥ 3.9
- `Python <https://www.python.org>`__ ≥ 3.10
- `NumPy <https://numpy.org>`__ ≥ 1.23
- `SciPy <https://scipy.org>`__ ≥ 1.9
- `Matplotlib <https://matplotlib.org>`__ ≥ 3.6
Expand Down
8 changes: 4 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ dependencies:
- joblib
- jupyter
- lazy_loader >=0.3
- matplotlib >=3.6
- matplotlib >=3.7
- mffpy >=0.5.7
- mne-qt-browser
- nibabel
- nilearn
- numba
- numpy >=1.23,<3
- numpy >=1.25,<3
- openmeeg >=2.5.5
- packaging
- pandas
- pandas >=2.0
- pillow
- pip
- pooch >=1.5
Expand All @@ -47,7 +47,7 @@ dependencies:
- qdarkstyle !=3.2.2
- qtpy
- scikit-learn
- scipy >=1.9
- scipy >=1.11
- sip
- snirf
- statsmodels
Expand Down
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
20 changes: 0 additions & 20 deletions mne/commands/mne_flash_bem.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ def run():
"been registered with the T1.mgz file."
),
)
parser.add_option(
"-n",
"--noconvert",
dest="noconvert",
action="store_true",
default=False,
help=(
"[DEPRECATED] Assume that the Flash MRI images "
"have already been converted to mgz files"
),
)
parser.add_option(
"-u",
"--unwarp",
Expand Down Expand Up @@ -139,15 +128,6 @@ def run():
help="Use copies instead of symlinks for surfaces",
action="store_true",
)
parser.add_option(
"-p",
"--flash-path",
dest="flash_path",
default=None,
help="[DEPRECATED] The directory containing flash5.mgz "
"files (defaults to "
"$SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps",
)

options, _ = parser.parse_args()

Expand Down
3 changes: 1 addition & 2 deletions mne/commands/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_flash_bem(tmp_path):

# First test without flash30
with ArgvSetter(
("-d", tempdir, "-s", "sample", "-n", "-r", "-3"),
("-d", tempdir, "-s", "sample", "-r", "-3"),
disable_stdout=False,
disable_stderr=False,
):
Expand All @@ -361,7 +361,6 @@ def test_flash_bem(tmp_path):
tempdir,
"-s",
"sample",
"-n",
"-3",
str(mridata_path / "flash" / "mef30.mgz"),
"-5",
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
Loading

0 comments on commit 637c231

Please sign in to comment.