Skip to content

Conversation

@mscheltienne
Copy link
Member

@mscheltienne mscheltienne commented Oct 9, 2024

@sappelhoff Is this better? c.f. #12843 (comment)

Now:

# %%
from pathlib import Path
import numpy as np
import mne

# create a dummy raw
sampling_freq = 1000
times = np.linspace(0, 1, sampling_freq, endpoint=False)
sine = np.sin(20 * np.pi * times)
cosine = np.cos(10 * np.pi * times)
data = np.array([sine, cosine])
info = mne.create_info(
    ch_names=["10 Hz sine", "5 Hz cosine"], ch_types=["misc"] * 2, sfreq=sampling_freq
)
raw = mne.io.RawArray(data, info)

# I want to set raw.filenames
a = Path.cwd() / "IDoNotExist.jpg"

# previous error: TypeError: 'tuple' object does not support item assignment
# new error: FileNotFoundError: File <...>/IDoNotExist.jpg not found.
raw.filenames = (a,)

# this gives the right error: FileNotFoundError: File <...>/IDoNotExist.jpg not found.
raw.filenames = [a]

# this works correctly
#path_to_file_that_exists = ...
#raw.filenames = [path_to_file_that_exists]

# this works, no errors raised (which is ok, because I am using a private attribute to circumvent checks)
raw._filenames = (a,)

@drammock drammock enabled auto-merge (squash) October 9, 2024 19:50
Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot!

@drammock drammock merged commit 06050bc into mne-tools:main Oct 9, 2024
@mscheltienne mscheltienne deleted the caast branch October 10, 2024 08:11
larsoner added a commit to larsoner/mne-python that referenced this pull request Oct 28, 2024
* upstream/main: (824 commits)
  Add `psd_args` to `plot_ica_sources` and `ICA.plot_sources` (mne-tools#12912)
  Fix GDF NumPy >= 2 (mne-tools#12909)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12908)
  ENH: Improve report usability (mne-tools#12901)
  MAINT: Avoid problematic PySide6 (mne-tools#12902)
  Sync README dependencies with pyproject.toml (mne-tools#12890)
  remove trailing slash from pybv base URL [ci skip] (mne-tools#12892)
  Cast tuple of filenames to list to improve error handling (mne-tools#12891)
  Website (mne-tools#12885)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12888)
  BUG: Fix bugs with coreg (mne-tools#12884)
  Bump mamba-org/setup-micromamba from 1 to 2 in the actions group (mne-tools#12887)
  Update spacing for comments in pyproject.toml (mne-tools#12886)
  make HTML repr for Forward match others (mne-tools#12883)
  MAINT: Linkchecks [circle deploy] (mne-tools#12882)
  Update roadmap (mne-tools#12872)
  [MRG] Require good and bad channels when creating a SpectrumArray object (mne-tools#12877)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12879)
  MAINT: Update code credit (mne-tools#12880)
  BUG: Fix bug with Path casting (mne-tools#12878)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants