From bd26444513b8a2801c143648c654f51dc2ba9b3e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 20:48:22 -0400 Subject: [PATCH] Fix Bug: When using Nuitka to package a project, an error occurred when reading the file: "KeyError: 'self'" #12923 --- .pre-commit-config.yaml | 2 +- mne/io/ant/ant.py | 3 +++ mne/io/array/array.py | 3 +++ mne/io/artemis123/artemis123.py | 2 ++ mne/io/boxy/boxy.py | 3 +++ mne/io/brainvision/brainvision.py | 3 +++ mne/io/bti/bti.py | 1 + mne/io/cnt/cnt.py | 1 + mne/io/ctf/ctf.py | 3 +++ mne/io/curry/curry.py | 2 ++ mne/io/edf/edf.py | 3 +++ mne/io/eeglab/eeglab.py | 3 +++ mne/io/egi/egi.py | 3 +++ mne/io/egi/egimff.py | 2 ++ mne/io/eximia/eximia.py | 3 +++ mne/io/eyelink/eyelink.py | 3 +++ mne/io/fiff/raw.py | 3 +++ mne/io/fil/fil.py | 2 ++ mne/io/hitachi/hitachi.py | 3 +++ mne/io/kit/kit.py | 3 +++ mne/io/nedf/nedf.py | 3 +++ mne/io/neuralynx/neuralynx.py | 2 ++ mne/io/nicolet/nicolet.py | 3 +++ mne/io/nihon/nihon.py | 2 ++ mne/io/nirx/nirx.py | 2 ++ mne/io/nsx/nsx.py | 3 +++ mne/io/persyst/persyst.py | 3 +++ mne/io/snirf/_snirf.py | 2 ++ 28 files changed, 70 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bdb943efd6..5a58d5d71fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/mne/io/ant/ant.py b/mne/io/ant/ant.py index 40e21133c8b..11a0d4b52be 100644 --- a/mne/io/ant/ant.py +++ b/mne/io/ant/ant.py @@ -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, diff --git a/mne/io/array/array.py b/mne/io/array/array.py index 0349cdf87dc..7afd95562d6 100644 --- a/mne/io/array/array.py +++ b/mne/io/array/array.py @@ -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 ) diff --git a/mne/io/artemis123/artemis123.py b/mne/io/artemis123/artemis123.py index 349a62822b6..8a3c069d67a 100644 --- a/mne/io/artemis123/artemis123.py +++ b/mne/io/artemis123/artemis123.py @@ -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, diff --git a/mne/io/boxy/boxy.py b/mne/io/boxy/boxy.py index 9a131730a51..c426f8d9209 100644 --- a/mne/io/boxy/boxy.py +++ b/mne/io/boxy/boxy.py @@ -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, diff --git a/mne/io/brainvision/brainvision.py b/mne/io/brainvision/brainvision.py index 07be6ab388a..13d439e13bf 100644 --- a/mne/io/brainvision/brainvision.py +++ b/mne/io/brainvision/brainvision.py @@ -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], diff --git a/mne/io/bti/bti.py b/mne/io/bti/bti.py index ff960a24703..6beec4fb050 100644 --- a/mne/io/bti/bti.py +++ b/mne/io/bti/bti.py @@ -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, diff --git a/mne/io/cnt/cnt.py b/mne/io/cnt/cnt.py index bd5fb4c2f29..0a47229a311 100644 --- a/mne/io/cnt/cnt.py +++ b/mne/io/cnt/cnt.py @@ -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, diff --git a/mne/io/ctf/ctf.py b/mne/io/ctf/ctf.py index 5e521f64b33..250e1155541 100644 --- a/mne/io/ctf/ctf.py +++ b/mne/io/ctf/ctf.py @@ -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, diff --git a/mne/io/curry/curry.py b/mne/io/curry/curry.py index 3e8347fba0d..00ab4877306 100644 --- a/mne/io/curry/curry.py +++ b/mne/io/curry/curry.py @@ -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, diff --git a/mne/io/edf/edf.py b/mne/io/edf/edf.py index 59ea7ab4870..08b8b53e3b3 100644 --- a/mne/io/edf/edf.py +++ b/mne/io/edf/edf.py @@ -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, diff --git a/mne/io/eeglab/eeglab.py b/mne/io/eeglab/eeglab.py index 3aa611b4e28..3bb3ab1f091 100644 --- a/mne/io/eeglab/eeglab.py +++ b/mne/io/eeglab/eeglab.py @@ -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, @@ -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, diff --git a/mne/io/egi/egi.py b/mne/io/egi/egi.py index 433758e19bf..be8e785a79d 100644 --- a/mne/io/egi/egi.py +++ b/mne/io/egi/egi.py @@ -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, diff --git a/mne/io/egi/egimff.py b/mne/io/egi/egimff.py index 51efd433455..1e20bd04dab 100644 --- a/mne/io/egi/egimff.py +++ b/mne/io/egi/egimff.py @@ -545,6 +545,8 @@ def __init__( % (pns_samples, eeg_samples) ) + __import__("inspect").currentframe().f_locals.update(locals()) + super().__init__( info, preload=preload, diff --git a/mne/io/eximia/eximia.py b/mne/io/eximia/eximia.py index 5d21879de32..cb72d8fdd6a 100644 --- a/mne/io/eximia/eximia.py +++ b/mne/io/eximia/eximia.py @@ -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, diff --git a/mne/io/eyelink/eyelink.py b/mne/io/eyelink/eyelink.py index 192a5555465..5e3ab8e9d8f 100644 --- a/mne/io/eyelink/eyelink.py +++ b/mne/io/eyelink/eyelink.py @@ -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, diff --git a/mne/io/fiff/raw.py b/mne/io/fiff/raw.py index 23b9498cb48..f2b60a7c81d 100644 --- a/mne/io/fiff/raw.py +++ b/mne/io/fiff/raw.py @@ -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, diff --git a/mne/io/fil/fil.py b/mne/io/fil/fil.py index a7dd157049a..181fce9ad10 100644 --- a/mne/io/fil/fil.py +++ b/mne/io/fil/fil.py @@ -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, diff --git a/mne/io/hitachi/hitachi.py b/mne/io/hitachi/hitachi.py index 9d8e27ba20d..7f87937ab43 100644 --- a/mne/io/hitachi/hitachi.py +++ b/mne/io/hitachi/hitachi.py @@ -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, diff --git a/mne/io/kit/kit.py b/mne/io/kit/kit.py index 58baade0bef..6620999e44a 100644 --- a/mne/io/kit/kit.py +++ b/mne/io/kit/kit.py @@ -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, diff --git a/mne/io/nedf/nedf.py b/mne/io/nedf/nedf.py index bd4054f1c16..a6b79d9a95e 100644 --- a/mne/io/nedf/nedf.py +++ b/mne/io/nedf/nedf.py @@ -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, diff --git a/mne/io/neuralynx/neuralynx.py b/mne/io/neuralynx/neuralynx.py index 2b9bed80ae8..af709003553 100644 --- a/mne/io/neuralynx/neuralynx.py +++ b/mne/io/neuralynx/neuralynx.py @@ -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], diff --git a/mne/io/nicolet/nicolet.py b/mne/io/nicolet/nicolet.py index f55cd77061d..d7bccde049d 100644 --- a/mne/io/nicolet/nicolet.py +++ b/mne/io/nicolet/nicolet.py @@ -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, diff --git a/mne/io/nihon/nihon.py b/mne/io/nihon/nihon.py index d6c992dd563..9ff4e743021 100644 --- a/mne/io/nihon/nihon.py +++ b/mne/io/nihon/nihon.py @@ -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, diff --git a/mne/io/nirx/nirx.py b/mne/io/nirx/nirx.py index 53a812e7a21..ce54e8580b7 100644 --- a/mne/io/nirx/nirx.py +++ b/mne/io/nirx/nirx.py @@ -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, diff --git a/mne/io/nsx/nsx.py b/mne/io/nsx/nsx.py index 1fc8a6968ea..9dc0c701602 100644 --- a/mne/io/nsx/nsx.py +++ b/mne/io/nsx/nsx.py @@ -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, diff --git a/mne/io/persyst/persyst.py b/mne/io/persyst/persyst.py index 8de44286445..8dce557afcd 100644 --- a/mne/io/persyst/persyst.py +++ b/mne/io/persyst/persyst.py @@ -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, diff --git a/mne/io/snirf/_snirf.py b/mne/io/snirf/_snirf.py index 3a3edca142b..7d150bfeab1 100644 --- a/mne/io/snirf/_snirf.py +++ b/mne/io/snirf/_snirf.py @@ -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,