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

BUG: warn magic isn't magical enough for contextlib.contextmanager #12913

Open
larsoner opened this issue Oct 22, 2024 · 1 comment
Open

BUG: warn magic isn't magical enough for contextlib.contextmanager #12913

larsoner opened this issue Oct 22, 2024 · 1 comment
Milestone

Comments

@larsoner
Copy link
Member

... I was wondering why the log contains next(self.gen):

>>> raw = mne.io.read_raw("/Users/clemens/Downloads/S01_MI/motorimagination_subject1_run1.gdf")
Extracting EDF parameters from /Users/clemens/Downloads/S01_MI/motorimagination_subject1_run1.gdf...
GDF file detected
Setting channel info structure...
Could not determine channel type of the following channels, they will be set as EEG:
F3, F1, Fz, F2, F4, FFC5h, FFC3h, FFC1h, FFC2h, FFC4h, FFC6h, FC5, FC3, FC1, FCz, FC2, FC4, FC6, FTT7h, FCC5h, FCC3h, FCC1h, FCC2h, FCC4h, FCC6h, FTT8h, C5, C3, C1, Cz, C2, C4, C6, TTP7h, CCP5h, CCP3h, CCP1h, CCP2h, CCP4h, CCP6h, TTP8h, CP5, CP3, CP1, CPz, CP2, CP4, CP6, CPP5h, CPP3h, CPP1h, CPP2h, CPP4h, CPP6h, P3, P1, Pz, P2, P4, PPO1h, PPO2h, eog-l, eog-m, eog-r, thumb_near, thumb_far, thumb_index, index_near, index_far, index_middle, middle_near, middle_far, middle_ring, ring_near, ring_far, ring_little, litte_near, litte_far, thumb_palm, wrist_bend, roll, pitch, gesture, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy, armeodummy
Creating raw.info structure...
/Users/clemens/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/contextlib.py:144: RuntimeWarning: Channel names are not unique, found duplicates for: {'armeodummy'}. Applying running numbers for duplicates.
  next(self.gen)

Originally posted by @cbrnr in #12909 (review)

@larsoner larsoner added this to the 1.9 milestone Oct 22, 2024
@larsoner
Copy link
Member Author

Probably not just your setup -- our warn does some magic to set the stacklevel such that it's out of the mne namespace. My guess is that some code is using a @contextlib.contextmanager and while traversing the stack, contextlib is outside the mne namespace so our warn stops there and emits a warning. Instead it should know contextlib is special in this way and keep going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant