From 0341739699050aca6320f5d58f26fe5206b17dd6 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 25 Sep 2024 15:20:05 +0200 Subject: [PATCH] add tests for untested lines --- mne_bids/tests/test_write.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mne_bids/tests/test_write.py b/mne_bids/tests/test_write.py index 607f4f709..954c1dcd6 100644 --- a/mne_bids/tests/test_write.py +++ b/mne_bids/tests/test_write.py @@ -4204,3 +4204,23 @@ def test_write_bids_with_age_weight_info(tmp_path): write_raw_bids(raw, bids_path=bids_path) bids_path = _bids_path.copy().update(root=bids_root, datatype="meg", run=2) write_raw_bids(raw, bids_path=bids_path) + + # Test that we get a value error when we have more than one item + raw.info["subject_info"] = { + "weight": np.array([75.0, 10.2]), + "height": np.array([180.0]), + } + + with pytest.raises(ValueError): + bids_path = _bids_path.copy().update(root=bids_root, datatype="meg", run=3) + write_raw_bids(raw, bids_path=bids_path) + + # Test that scalar data is handled correctly + + raw.info["subject_info"] = { + "weight": 75.0, + "height": np.array([180.0]), + } + + bids_path = _bids_path.copy().update(root=bids_root, datatype="meg", run=3) + write_raw_bids(raw, bids_path=bids_path)