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

clean up some deprecations #12067

Merged
merged 3 commits into from
Oct 4, 2023
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
45 changes: 1 addition & 44 deletions mne/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@

import lazy_loader as lazy

__getattr_lz__, __dir__, __all__ = lazy.attach(
__getattr__, __dir__, __all__ = lazy.attach(
__name__,
submodules=[
"constants",
"pick",
# Remove these three in 1.6 along with their .py files
"proj",
"meas_info",
"reference",
],
submod_attrs={
"base": ["BaseRaw", "concatenate_raws", "match_channel_orders"],
Expand Down Expand Up @@ -61,42 +57,3 @@
],
},
)


# Remove in 1.6 and change __getattr_lz__ to __getattr__
from ..utils import warn as _warn
from .._fiff.reference import (
set_eeg_reference as _set_eeg_reference,
set_bipolar_reference as _set_bipolar_reference,
add_reference_channels as _add_referenc_channels,
)
from .._fiff.meas_info import Info as _Info


def __getattr__(name):
"""Try getting attribute from fiff submodule."""
if name in (
"set_eeg_reference",
"set_bipolar_reference",
"add_reference_channels",
):
_warn(
f"mne.io.{name} is deprecated and will be removed in 1.6, "
"use mne.{name} instead",
FutureWarning,
)
return globals()[f"_{name}"]
elif name == "RawFIF":
_warn(
"RawFIF is deprecated and will be removed in 1.6, use Raw instead",
FutureWarning,
)
name = "Raw"
elif name == "Info":
_warn(
"mne.io.Info is deprecated and will be removed in 1.6, "
"use mne.Info instead",
FutureWarning,
)
return _Info
return __getattr_lz__(name)
10 changes: 0 additions & 10 deletions mne/io/tests/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
# License: BSD-3-Clause

from mne.io import Raw
import pytest


Expand All @@ -28,12 +27,3 @@ def test_deprecation():

with pytest.warns(FutureWarning, match=r"mne\.io\.meas_info\.read_info is dep"):
meas_info.read_info
with pytest.warns(FutureWarning, match="RawFIF is deprecated"):
mne.io.RawFIF
with pytest.warns(FutureWarning, match="RawFIF is deprecated"):
from mne.io import RawFIF
assert RawFIF is Raw
with pytest.warns(FutureWarning, match="set_eeg_reference is deprecated"):
mne.io.set_eeg_reference
with pytest.warns(FutureWarning, match=r"use mne\.Info instead"):
mne.io.Info
34 changes: 1 addition & 33 deletions mne/source_space/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import lazy_loader as lazy

__getattr_lz__, __dir__, __all__ = lazy.attach(
__getattr__, __dir__, __all__ = lazy.attach(
__name__,
submodules=["_source_space"],
submod_attrs={
Expand All @@ -20,35 +20,3 @@
],
},
)


from . import _source_space
from ..utils import warn as _warn


def __getattr__(name):
msg = out = None
try:
return __getattr_lz__(name)
except AttributeError:
try:
out = getattr(_source_space, name)
except AttributeError:
pass # will raise original error below
else:
# These should be removed (they're in the MNE namespace)
msg = f"mne.source_space.{name} is deprecated and will be removed in 1.6, "
if name in (
"read_freesurfer_lut",
"get_mni_fiducials",
"get_volume_labels_from_aseg",
"get_volume_labels_from_src",
):
msg += f"use mne.{name} instead"
else:
msg += "use public API instead"
if out is None:
raise
if msg is not None:
_warn(msg, FutureWarning)
return out
6 changes: 0 additions & 6 deletions mne/source_space/tests/test_source_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,6 @@ def test_get_decimated_surfaces(src, n, nv):
assert_array_equal(np.unique(s["tris"]), np.arange(nv))


def test_deprecation():
"""Test deprecation of mne.source_space functions."""
with pytest.warns(FutureWarning, match="use mne.get_volume_labels_from_src"):
mne.source_space.get_volume_labels_from_src


# The following code was used to generate small-src.fif.gz.
# Unfortunately the C code bombs when trying to add source space distances,
# possibly due to incomplete "faking" of a smaller surface on our part here.
Expand Down
Loading