Skip to content

Commit cc0fc70

Browse files
[MRG] Ensure check is passed to update function (#1411)
* Update path.py * Added test, Fix private function also within `_get_matching_bidspaths_from_filesystem`, the check parameter was being passed so it would not work when trying to generate a fpath Added test to check for the fpath creation with datatype not in VALID_DATATYPES when check=False * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a619cb7 commit cc0fc70

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

mne_bids/path.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ def __init__(
410410
):
411411
raise ValueError("At least one parameter must be given.")
412412

413-
self.check = check
414-
415413
self.update(
416414
subject=subject,
417415
session=session,
@@ -427,6 +425,7 @@ def __init__(
427425
datatype=datatype,
428426
suffix=suffix,
429427
extension=extension,
428+
check=check,
430429
)
431430

432431
@property
@@ -924,10 +923,10 @@ def fpath(self):
924923
return bids_fpath
925924

926925
def update(self, *, check=None, **kwargs):
927-
"""Update inplace BIDS entity key/value pairs in object.
926+
"""Update in-place BIDS entity key/value pairs in object.
928927
929928
``run`` and ``split`` are auto-converted to have two
930-
digits. For example, if ``run=1``, then it will nbecome ``run='01'``.
929+
digits. For example, if ``run=1``, then it will become ``run='01'``.
931930
932931
Also performs error checks on various entities to
933932
adhere to the BIDS specification. Specifically:
@@ -1364,12 +1363,13 @@ def _get_matching_bidspaths_from_filesystem(bids_path):
13641363
sub, ses = bids_path.subject, bids_path.session
13651364
datatype = bids_path.datatype
13661365
basename, bids_root = bids_path.basename, bids_path.root
1366+
check = bids_path.check
13671367

13681368
if datatype is None:
13691369
datatype = _infer_datatype(root=bids_root, sub=sub, ses=ses)
13701370

13711371
data_dir = BIDSPath(
1372-
subject=sub, session=ses, datatype=datatype, root=bids_root
1372+
subject=sub, session=ses, datatype=datatype, root=bids_root, check=check
13731373
).directory
13741374

13751375
# For BTi data, just return the directory with a '.pdf' extension

mne_bids/tests/test_path.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,20 @@ def test_datasetdescription_with_bidspath(return_bids_test_dir):
16121612
)
16131613

16141614

1615+
@testing.requires_testing_data
1616+
def test_update_check(return_bids_test_dir):
1617+
"""Test check argument is passed BIDSPath properly."""
1618+
bids_path = BIDSPath(
1619+
root=return_bids_test_dir,
1620+
check=False,
1621+
)
1622+
bids_path.update(datatype="eyetrack")
1623+
assert (
1624+
bids_path.fpath.as_posix()
1625+
== Path(f"{return_bids_test_dir}/eyetrack").as_posix()
1626+
)
1627+
1628+
16151629
def test_update_fail_check_no_change():
16161630
"""Test BIDSPath.check works in preventing invalid changes."""
16171631
bids_path = BIDSPath(subject="test")

0 commit comments

Comments
 (0)