Skip to content

Commit 50cbfd0

Browse files
committed
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
1 parent 4cc5da3 commit 50cbfd0

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

mne_bids/path.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,10 @@ def fpath(self):
923923
return bids_fpath
924924

925925
def update(self, *, check=None, **kwargs):
926-
"""Update inplace BIDS entity key/value pairs in object.
926+
"""Update in-place BIDS entity key/value pairs in object.
927927
928928
``run`` and ``split`` are auto-converted to have two
929-
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'``.
930930
931931
Also performs error checks on various entities to
932932
adhere to the BIDS specification. Specifically:
@@ -1363,12 +1363,14 @@ def _get_matching_bidspaths_from_filesystem(bids_path):
13631363
sub, ses = bids_path.subject, bids_path.session
13641364
datatype = bids_path.datatype
13651365
basename, bids_root = bids_path.basename, bids_path.root
1366+
check = bids_path.check
13661367

13671368
if datatype is None:
13681369
datatype = _infer_datatype(root=bids_root, sub=sub, ses=ses)
13691370

13701371
data_dir = BIDSPath(
1371-
subject=sub, session=ses, datatype=datatype, root=bids_root
1372+
subject=sub, session=ses, datatype=datatype, root=bids_root,
1373+
check=check
13721374
).directory
13731375

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

mne_bids/tests/test_path.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,17 @@ def test_datasetdescription_with_bidspath(return_bids_test_dir):
16111611
== Path(f"{return_bids_test_dir}/dataset_description.json").as_posix()
16121612
)
16131613

1614+
@testing.requires_testing_data
1615+
def test_update_check(return_bids_test_dir):
1616+
"""Test check argument is passed BIDSPath properly."""
1617+
bids_path = BIDSPath(
1618+
root=return_bids_test_dir,
1619+
check=False,
1620+
)
1621+
bids_path.update(datatype="eyetrack")
1622+
assert (bids_path.fpath.as_posix()
1623+
== Path(f"{return_bids_test_dir}/eyetrack").as_posix())
1624+
16141625

16151626
def test_update_fail_check_no_change():
16161627
"""Test BIDSPath.check works in preventing invalid changes."""

0 commit comments

Comments
 (0)