Skip to content

Commit

Permalink
FIX: More
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Aug 20, 2024
1 parent 89d4c88 commit 572ee24
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mne_bids/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ def search_folder_for_text(
def _check_max_depth(max_depth):
"""Check that max depth is a proper input."""
msg = "`max_depth` must be a positive integer or None"
if not isinstance(max_depth, (int, type(None))):
if not isinstance(max_depth, int | type(None)):
raise ValueError(msg)
if max_depth is None:
max_depth = float("inf")
Expand Down Expand Up @@ -2217,7 +2217,7 @@ def _infer_datatype(*, root, sub, ses):

def _path_to_str(var):
"""Make sure var is a string or Path, return string representation."""
if not isinstance(var, (Path, str)):
if not isinstance(var, Path | str):
raise ValueError(
f"All path parameters must be either strings or "
f"pathlib.Path objects. Found type {type(var)}."
Expand Down
2 changes: 1 addition & 1 deletion mne_bids/tsv_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _from_tsv(fname, dtypes=None):
data_dict = OrderedDict()
if dtypes is None:
dtypes = [str] * info.shape[1]
if not isinstance(dtypes, (list, tuple)):
if not isinstance(dtypes, list | tuple):
dtypes = [dtypes] * info.shape[1]
if not len(dtypes) == info.shape[1]:
raise ValueError(
Expand Down
4 changes: 2 additions & 2 deletions mne_bids/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def _age_on_date(bday, exp_date):
def _check_types(variables):
"""Make sure all vars are str or None."""
for var in variables:
if not isinstance(var, (str, type(None))):
if not isinstance(var, str | type(None)):
raise ValueError(
f"You supplied a value ({var}) of type "
f"{type(var)}, where a string or None was "
Expand Down Expand Up @@ -271,7 +271,7 @@ def _get_mrk_meas_date(mrk):
"""Find the measurement date from a KIT marker file."""
info = get_kit_info(mrk, False)[0]
meas_date = info.get("meas_date", None)
if isinstance(meas_date, (tuple, list, np.ndarray)):
if isinstance(meas_date, tuple | list | np.ndarray):
meas_date = meas_date[0]
if isinstance(meas_date, datetime):
meas_datetime = meas_date
Expand Down
6 changes: 3 additions & 3 deletions mne_bids/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@


def _is_numeric(n):
return isinstance(n, (np.integer, np.floating, int, float))
return isinstance(n, np.integer | np.floating | int | float)


def _channels_tsv(raw, fname, overwrite=False):
Expand Down Expand Up @@ -459,7 +459,7 @@ def _participants_tsv(raw, subject_id, fname, overwrite=False):
if isinstance(age, tuple): # can be removed once MNE >= 1.8 is required
age = date(*age)
meas_date = raw.info.get("meas_date", None)
if isinstance(meas_date, (tuple, list, np.ndarray)):
if isinstance(meas_date, tuple | list | np.ndarray):
meas_date = meas_date[0]

if meas_date is not None and age is not None:
Expand Down Expand Up @@ -2267,7 +2267,7 @@ def _get_t1w_mgh(fs_subject, fs_subjects_dir):
def _get_landmarks(landmarks, image_nii, kind=""):
import nibabel as nib

if isinstance(landmarks, (str, Path)):
if isinstance(landmarks, str | Path):
landmarks, coord_frame = read_fiducials(landmarks)
landmarks = np.array(
[landmark["r"] for landmark in landmarks], dtype=float
Expand Down

0 comments on commit 572ee24

Please sign in to comment.