Skip to content

Commit 7ffcc2a

Browse files
CedricCondayCedricConday
andauthored
Add missing f-string prefixes to error messages (mne-tools#14008)
Co-authored-by: CedricConday <cedric@conday.digital>
1 parent c344ec1 commit 7ffcc2a

5 files changed

Lines changed: 5 additions & 4 deletions

File tree

doc/changes/dev/14008.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed several error messages that displayed literal ``{...}`` placeholder text instead of the intended values, due to a missing ``f`` string prefix (in :class:`mne.SourceEstimate`, :func:`mne.io.read_raw_hitachi`, :func:`mne.preprocessing.compute_current_source_density`, and :func:`mne.preprocessing.maxwell_filter`), by `Cedric Conday`_.

mne/io/hitachi/hitachi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def __init__(self, fname, preload=False, *, verbose=None):
9595
info = infos[0]
9696
if len(set(last_samps)) != 1:
9797
raise RuntimeError(
98-
"All files must have the same number of samples, got: {last_samps}"
98+
f"All files must have the same number of samples, got: {last_samps}"
9999
)
100100
last_samps = [last_samps[0]]
101101
raw_extras = [dict(probes=probes)]

mne/preprocessing/_csd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def compute_current_source_density(
153153
_validate_type(z, "numeric", "z")
154154
_validate_type(radius, "numeric", "radius")
155155
if radius <= 0:
156-
raise ValueError("sphere radius must be greater than 0, got {radius}")
156+
raise ValueError(f"sphere radius must be greater than 0, got {radius}")
157157

158158
pos = np.array([inst.info["chs"][pick]["loc"][:3] for pick in picks])
159159
if not np.isfinite(pos).all() or np.isclose(pos, 0.0).all(1).any():

mne/preprocessing/maxwell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ def _check_usable(inst, ignore_ref):
15271527
raise RuntimeError(
15281528
"Maxwell filter cannot be done on compensated "
15291529
"channels (data have been compensated with "
1530-
"grade {current_comp}) when ignore_ref=True"
1530+
f"grade {current_comp}) when ignore_ref=True"
15311531
)
15321532

15331533

mne/source_estimate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def __init__(self, data, vertices, tmin, tstep, subject=None, verbose=None):
513513
)
514514
if sens_data.ndim != 2:
515515
raise ValueError(
516-
"The sensor data must have 2 dimensions, got {sens_data.ndim}"
516+
f"The sensor data must have 2 dimensions, got {sens_data.ndim}"
517517
)
518518

519519
_validate_type(vertices, list, "vertices")

0 commit comments

Comments
 (0)