Skip to content

Commit

Permalink
Try fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Oct 16, 2023
1 parent aba3e1b commit 551bfc0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion xcp_d/tests/test_interfaces_bids.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Tests for framewise displacement calculation."""
from nipype.interfaces.base import isdefined

from xcp_d.interfaces import bids


Expand Down Expand Up @@ -34,4 +36,4 @@ def test_infer_bids_uris():
dataset_path=dataset_path,
)
out = infer_bids_uris.run()
assert out.outputs.bids_uris == []
assert not isdefined(out.outputs.bids_uris)
4 changes: 2 additions & 2 deletions xcp_d/tests/test_utils_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ def test_listify():
]
outputs = [
[1],
[1],
(1,),
["a"],
["a"],
["a", ["b", "c"]],
["a", "b"],
("a", "b"),
]
for i, input_ in enumerate(inputs):
expected_output = outputs[i]
Expand Down
8 changes: 4 additions & 4 deletions xcp_d/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ def _make_uri(in_file, dataset_name, dataset_path):
ValueError
If ``in_file`` is not relative to ``dataset_path``.
"""
bids_uri = [f"bids:{dataset_name}:{str(Path(in_file).relative_to(dataset_path))}"]
bids_uri = f"bids:{dataset_name}:{str(Path(in_file).relative_to(dataset_path))}"
return bids_uri


Expand All @@ -1001,7 +1001,7 @@ def _make_xcpd_uri(out_file, output_dir):
if isinstance(out_file, list):
return [_make_uri(of, "xcp_d", dataset_path) for of in out_file]
else:
return _make_uri(out_file, "xcp_d", dataset_path)
return [_make_uri(out_file, "xcp_d", dataset_path)]


def _make_preproc_uri(out_file, fmri_dir):
Expand All @@ -1011,7 +1011,7 @@ def _make_preproc_uri(out_file, fmri_dir):
if isinstance(out_file, list):
return [_make_uri(of, "preprocessed", fmri_dir) for of in out_file]
else:
return _make_uri(out_file, "preprocessed", fmri_dir)
return [_make_uri(out_file, "preprocessed", fmri_dir)]


def _make_custom_uri(out_file):
Expand All @@ -1023,4 +1023,4 @@ def _make_custom_uri(out_file):
if isinstance(out_file, list):
return [_make_uri(of, "custom_confounds", os.path.dirname(of)) for of in out_file]
else:
return _make_uri(out_file, "custom_confounds", os.path.dirname(out_file))
return [_make_uri(out_file, "custom_confounds", os.path.dirname(out_file))]
4 changes: 3 additions & 1 deletion xcp_d/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,16 @@ def _make_dictionary(metadata=None, **kwargs):
"""
from copy import deepcopy

from xcp_d.utils.utils import _listify

if metadata:
out_metadata = deepcopy(metadata)
for key, value in kwargs.items():
if key not in metadata.keys():
out_metadata[key] = value
elif isinstance(value, list):
# Append the values if they're a list
out_metadata[key] += value
out_metadata[key] = _listify(out_metadata[key]) + value
else:
# Overwrite the old value
out_metadata[key] = value
Expand Down

0 comments on commit 551bfc0

Please sign in to comment.