Skip to content

Commit

Permalink
Fix Bug: When using Nuitka to package a project, an error occurred wh…
Browse files Browse the repository at this point in the history
…en reading the file: "KeyError: 'self'" mne-tools#12923
  • Loading branch information
pre-commit-ci[bot] authored and CrazySJX committed Oct 30, 2024
1 parent e15292f commit bd26444
Show file tree
Hide file tree
Showing 28 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# Ruff mne
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.7.1
hooks:
- id: ruff
name: ruff lint mne
Expand Down
3 changes: 3 additions & 0 deletions mne/io/ant/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ def __init__(
"first_samples": np.array(first_samps),
"last_samples": np.array(last_samps),
}

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload=preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/array/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def __init__(self, data, info, first_samp=0, copy="auto", verbose=None):
f"Creating RawArray with {dtype.__name__} data, "
f"n_channels={data.shape[0]}, n_times={data.shape[1]}"
)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info, data, first_samps=(int(first_samp),), dtype=dtype, verbose=verbose
)
Expand Down
2 changes: 2 additions & 0 deletions mne/io/artemis123/artemis123.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ def __init__(

last_samps = [header_info.get("num_samples", 1) - 1]

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/boxy/boxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ def __init__(self, fname, preload=False, verbose=None):
assert len(raw_extras["offsets"]) == delta + 1
if filetype == "non-parsed":
delta //= raw_extras["source_num"]

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/brainvision/brainvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def __init__(

orig_format = "single" if isinstance(fmt, dict) else fmt
raw_extras = dict(offsets=offsets, fmt=fmt, order=order, n_samples=n_samples)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
last_samps=[n_samples - 1],
Expand Down
1 change: 1 addition & 0 deletions mne/io/bti/bti.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,7 @@ def __init__(
filename = bti_info["pdf"]
if isinstance(filename, BytesIO):
filename = None
__import__("inspect").currentframe().f_locals.update(locals())
super().__init__(
info,
preload,
Expand Down
1 change: 1 addition & 0 deletions mne/io/cnt/cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ def __init__(
"please use mne.io.read_raw_ant instead."
)
last_samps = [cnt_info["n_samples"] - 1]
__import__("inspect").currentframe().f_locals.update(locals())
super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/ctf/ctf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def __init__(
f"file(s): {missing_names}, and the following file(s) had no "
f"valid samples: {no_samps}"
)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/curry/curry.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ def __init__(self, fname, preload=False, verbose=None):
last_samps = [n_samples - 1]
raw_extras = dict(is_ascii=is_ascii)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/edf/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def __init__(

# Raw attributes
last_samps = [edf_info["nsamples"] - 1]

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/eeglab/eeglab.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ def __init__(
data_fname = _check_eeglab_fname(input_fname, eeg.data)
logger.info(f"Reading {data_fname}")

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand All @@ -487,6 +489,7 @@ def __init__(
data = np.empty((n_chan, n_times), dtype=float)
data[:n_chan] = eeg.data
data *= CAL
__import__("inspect").currentframe().f_locals.update(locals())
super().__init__(
info,
data,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/egi/egi.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ def __init__(
orig_format = (
egi_info["orig_format"] if egi_info["orig_format"] != "float" else "single"
)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/egi/egimff.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ def __init__(
% (pns_samples, eeg_samples)
)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload=preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/eximia/eximia.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def __init__(self, fname, preload=False, verbose=None):
)
for ch, cal in zip(info["chs"], cals):
ch["cal"] = cal

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload=preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/eyelink/eyelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def __init__(
fname, find_overlaps, overlap_threshold, apply_offsets
)
# ======================== Create Raw Object =========================

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload=eye_ch_data,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/fiff/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def __init__(
fname = _path_from_fname(fname)

_check_raw_compatibility(raws)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
copy.deepcopy(raws[0].info),
preload=False,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/fil/fil.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def __init__(self, binfile, precision="single", preload=False):
meg = json.load(fid)
info = _compose_meas_info(meg, chans)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/hitachi/hitachi.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def __init__(self, fname, preload=False, *, verbose=None):
raw_extras = [dict(probes=probes)]
# One representative filename is good enough here
# (additional filenames indicate temporal concat, not ch concat)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/kit/kit.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def __init__(
last_samps = [kit_info["n_samples"] - 1]
self._raw_extras = [kit_info]
_set_stimchannels(self, info, stim, stim_code)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/nedf/nedf.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def __init__(self, filename, preload=False, verbose=None):
with info._unlock():
info["meas_date"] = header["meas_date"]
raw_extra = dict(dt=dt, dt_last=dt_last, n_full=n_full)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload=preload,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/neuralynx/neuralynx.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ def __init__(
description=["BAD_ACQ_SKIP"] * len(gap_start_ids),
)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info=info,
last_samps=[sizes_sorted.sum() - 1],
Expand Down
3 changes: 3 additions & 0 deletions mne/io/nicolet/nicolet.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def __init__(
input_fname = path.abspath(input_fname)
info, header_info = _get_nicolet_info(input_fname, ch_type, eog, ecg, emg, misc)
last_samps = [header_info["num_samples"] - 1]

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/nihon/nihon.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ def __init__(self, fname, preload=False, verbose=None):
info["chs"][i_ch]["range"] = t_range
info["chs"][i_ch]["cal"] = 1 / t_range

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload=preload,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/nirx/nirx.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ def __init__(self, fname, saturated, *, preload=False, encoding=None, verbose=No
annot_mask |= mask
nan_mask[key] = None # shouldn't need again

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/nsx/nsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ def __init__(
) = _get_hdr_info(input_fname, stim_channel=stim_channel, eog=eog, misc=misc)
raw_extras["orig_format"] = orig_format
first_samps = (raw_extras["timestamp"][0],)

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
first_samps=first_samps,
Expand Down
3 changes: 3 additions & 0 deletions mne/io/persyst/persyst.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ def __init__(self, fname, preload=False, verbose=None):

raw_extras = {"dtype": dtype, "n_chs": n_chs, "n_samples": n_samples}
# create Raw object

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down
2 changes: 2 additions & 0 deletions mne/io/snirf/_snirf.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ def natural_keys(text):
with info._unlock():
info["subject_info"]["birthday"] = birthday

__import__("inspect").currentframe().f_locals.update(locals())

super().__init__(
info,
preload,
Expand Down

0 comments on commit bd26444

Please sign in to comment.