Skip to content

Commit 56851d5

Browse files
drammocksnwnde
authored andcommitted
clean up some deprecations (mne-tools#12067)
1 parent 0515b02 commit 56851d5

File tree

4 files changed

+2
-93
lines changed

4 files changed

+2
-93
lines changed

mne/io/__init__.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77

88
import lazy_loader as lazy
99

10-
__getattr_lz__, __dir__, __all__ = lazy.attach(
10+
__getattr__, __dir__, __all__ = lazy.attach(
1111
__name__,
1212
submodules=[
1313
"constants",
1414
"pick",
15-
# Remove these three in 1.6 along with their .py files
16-
"proj",
17-
"meas_info",
18-
"reference",
1915
],
2016
submod_attrs={
2117
"base": ["BaseRaw", "concatenate_raws", "match_channel_orders"],
@@ -61,42 +57,3 @@
6157
],
6258
},
6359
)
64-
65-
66-
# Remove in 1.6 and change __getattr_lz__ to __getattr__
67-
from ..utils import warn as _warn
68-
from .._fiff.reference import (
69-
set_eeg_reference as _set_eeg_reference,
70-
set_bipolar_reference as _set_bipolar_reference,
71-
add_reference_channels as _add_referenc_channels,
72-
)
73-
from .._fiff.meas_info import Info as _Info
74-
75-
76-
def __getattr__(name):
77-
"""Try getting attribute from fiff submodule."""
78-
if name in (
79-
"set_eeg_reference",
80-
"set_bipolar_reference",
81-
"add_reference_channels",
82-
):
83-
_warn(
84-
f"mne.io.{name} is deprecated and will be removed in 1.6, "
85-
"use mne.{name} instead",
86-
FutureWarning,
87-
)
88-
return globals()[f"_{name}"]
89-
elif name == "RawFIF":
90-
_warn(
91-
"RawFIF is deprecated and will be removed in 1.6, use Raw instead",
92-
FutureWarning,
93-
)
94-
name = "Raw"
95-
elif name == "Info":
96-
_warn(
97-
"mne.io.Info is deprecated and will be removed in 1.6, "
98-
"use mne.Info instead",
99-
FutureWarning,
100-
)
101-
return _Info
102-
return __getattr_lz__(name)

mne/io/tests/test_deprecation.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#
55
# License: BSD-3-Clause
66

7-
from mne.io import Raw
87
import pytest
98

109

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

2928
with pytest.warns(FutureWarning, match=r"mne\.io\.meas_info\.read_info is dep"):
3029
meas_info.read_info
31-
with pytest.warns(FutureWarning, match="RawFIF is deprecated"):
32-
mne.io.RawFIF
33-
with pytest.warns(FutureWarning, match="RawFIF is deprecated"):
34-
from mne.io import RawFIF
35-
assert RawFIF is Raw
36-
with pytest.warns(FutureWarning, match="set_eeg_reference is deprecated"):
37-
mne.io.set_eeg_reference
38-
with pytest.warns(FutureWarning, match=r"use mne\.Info instead"):
39-
mne.io.Info

mne/source_space/__init__.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import lazy_loader as lazy
44

5-
__getattr_lz__, __dir__, __all__ = lazy.attach(
5+
__getattr__, __dir__, __all__ = lazy.attach(
66
__name__,
77
submodules=["_source_space"],
88
submod_attrs={
@@ -20,35 +20,3 @@
2020
],
2121
},
2222
)
23-
24-
25-
from . import _source_space
26-
from ..utils import warn as _warn
27-
28-
29-
def __getattr__(name):
30-
msg = out = None
31-
try:
32-
return __getattr_lz__(name)
33-
except AttributeError:
34-
try:
35-
out = getattr(_source_space, name)
36-
except AttributeError:
37-
pass # will raise original error below
38-
else:
39-
# These should be removed (they're in the MNE namespace)
40-
msg = f"mne.source_space.{name} is deprecated and will be removed in 1.6, "
41-
if name in (
42-
"read_freesurfer_lut",
43-
"get_mni_fiducials",
44-
"get_volume_labels_from_aseg",
45-
"get_volume_labels_from_src",
46-
):
47-
msg += f"use mne.{name} instead"
48-
else:
49-
msg += "use public API instead"
50-
if out is None:
51-
raise
52-
if msg is not None:
53-
_warn(msg, FutureWarning)
54-
return out

mne/source_space/tests/test_source_space.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,12 +1020,6 @@ def test_get_decimated_surfaces(src, n, nv):
10201020
assert_array_equal(np.unique(s["tris"]), np.arange(nv))
10211021

10221022

1023-
def test_deprecation():
1024-
"""Test deprecation of mne.source_space functions."""
1025-
with pytest.warns(FutureWarning, match="use mne.get_volume_labels_from_src"):
1026-
mne.source_space.get_volume_labels_from_src
1027-
1028-
10291023
# The following code was used to generate small-src.fif.gz.
10301024
# Unfortunately the C code bombs when trying to add source space distances,
10311025
# possibly due to incomplete "faking" of a smaller surface on our part here.

0 commit comments

Comments
 (0)