Skip to content

Commit f5f1764

Browse files
authored
Merge branch 'main' into issue-13826
2 parents 1021162 + dae2754 commit f5f1764

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

doc/changes/dev/13673.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reorganized EDF submodule structure by moving private functionality into the public ``mne.io`` namespace to improve module consistency and avoid exposing private modules in the Credits page, by `Aniket Singh Yadav`_.

doc/sphinxext/credit_tools.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ def generate_credit_rst(app=None, *, verbose=False):
345345
globs["bin/*"] = "mne.commands"
346346
globs["mne/morph_map.py"] = "mne.surface"
347347
globs["mne/baseline.py"] = "mne.epochs"
348+
globs["mne/io/edf/_open.py"] = "mne.io"
349+
globs["mne/_edf/open.py"] = "mne.io"
348350
for key in """
349351
parallel.py rank.py misc.py data/*.* defaults.py fixes.py icons/*.* icons.*
350352
""".strip().split():
@@ -392,15 +394,30 @@ def generate_credit_rst(app=None, *, verbose=False):
392394
other_files.add(fname)
393395
mod = "other"
394396
for e, pm in counts.items():
395-
if mod == "mne._fiff":
396-
raise RuntimeError
397+
# Assert no private (_-prefixed) submodules appear without a redirect
398+
if mod.startswith("mne.") and mod.split(".")[-1].startswith("_"):
399+
raise RuntimeError(
400+
f"Private submodule {mod!r} found in credit page for {fname!r}. "
401+
"Add an override in credit_tools.py to remap it to a public module."
402+
)
397403
# sanity check a bit
398404
if mod != "null" and (".png" in fname or "/manual/" in fname):
399405
raise RuntimeError(f"Unexpected {mod} {fname}")
400406
mod_stats[mod][e] += pm
401407
mod_stats["mne"][e] += pm
402408
total_lines += pm
403409
mod_stats.pop("null") # stuff we shouldn't give credit for
410+
# Assert no private (_-prefixed) submodule names remain after null-removal
411+
private_mods = [
412+
m
413+
for m in mod_stats
414+
if m.startswith("mne.") and m.split(".")[-1].startswith("_")
415+
]
416+
if private_mods:
417+
raise RuntimeError(
418+
f"Private submodule(s) {private_mods} found in credit page. "
419+
"Update credit_tools.py to remap them to a public module."
420+
)
404421
mod_stats = dict(
405422
(k, mod_stats[k])
406423
for k in sorted(

mne/_edf/open.py renamed to mne/io/edf/_open.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
# License: BSD-3-Clause
33
# Copyright the MNE-Python contributors.
44

5-
# Maybe we can move this one to utils or something like that.
65
from pathlib import Path
76

8-
from mne._fiff.open import _NoCloseRead
9-
10-
from ..utils import _file_like, _validate_type, logger
7+
from ..._fiff.open import _NoCloseRead
8+
from ...utils import _file_like, _validate_type, logger
119

1210

1311
def _gdf_edf_get_fid(fname, **kwargs):

mne/io/edf/edf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import numpy as np
1414
from scipy.interpolate import interp1d
1515

16-
from ..._edf.open import _gdf_edf_get_fid
1716
from ..._fiff.constants import FIFF
1817
from ..._fiff.meas_info import _empty_info, _unique_channel_names
1918
from ..._fiff.utils import _blk_read_lims, _mult_cal_one
@@ -30,6 +29,7 @@
3029
warn,
3130
)
3231
from ..base import BaseRaw, _get_scaling
32+
from ._open import _gdf_edf_get_fid
3333

3434

3535
class FileType(Enum):

0 commit comments

Comments
 (0)