From 188b6deba0d388799b6e479f424de8b78555027a Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 28 Aug 2022 11:40:40 +0100 Subject: [PATCH 1/3] add test for edf units param --- mne/io/edf/edf.py | 2 +- mne/io/edf/tests/test_edf.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mne/io/edf/edf.py b/mne/io/edf/edf.py index f71b782cb8c..0b2c5f79589 100644 --- a/mne/io/edf/edf.py +++ b/mne/io/edf/edf.py @@ -147,7 +147,7 @@ def __init__(self, input_fname, eog=None, misc=None, stim_channel='auto', units = dict() for k, (this_ch, this_unit) in enumerate(orig_units.items()): - if this_unit != "" and this_unit in units: + if this_unit != "" and this_ch in units: raise ValueError(f'Unit for channel {this_ch} is present in ' 'the file. Cannot overwrite it with the ' 'units argument.') diff --git a/mne/io/edf/tests/test_edf.py b/mne/io/edf/tests/test_edf.py index 7426e76b66f..1acddf5d8f2 100644 --- a/mne/io/edf/tests/test_edf.py +++ b/mne/io/edf/tests/test_edf.py @@ -77,6 +77,15 @@ def test_orig_units(): assert orig_units['A1'] == 'µV' # formerly 'uV' edit by _check_orig_units +def test_units_params(): + """Test enforcing original channel units.""" + + with pytest.raises(ValueError, + match=r"Unit for channel .* is present .* Cannot " + "overwrite it"): + raw = read_raw_edf(edf_path, units='V', preload=True) + + def test_subject_info(tmp_path): """Test exposure of original channel units.""" raw = read_raw_edf(edf_path) From afdf0e37a781943d65e94c1feeba60a551a70cf3 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 28 Aug 2022 12:02:12 +0100 Subject: [PATCH 2/3] flake8 --- mne/io/edf/tests/test_edf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/io/edf/tests/test_edf.py b/mne/io/edf/tests/test_edf.py index 1acddf5d8f2..39597923915 100644 --- a/mne/io/edf/tests/test_edf.py +++ b/mne/io/edf/tests/test_edf.py @@ -83,7 +83,7 @@ def test_units_params(): with pytest.raises(ValueError, match=r"Unit for channel .* is present .* Cannot " "overwrite it"): - raw = read_raw_edf(edf_path, units='V', preload=True) + _ = read_raw_edf(edf_path, units='V', preload=True) def test_subject_info(tmp_path): From ba922795ab1b43e6549bc1aad3334be8f88d9b98 Mon Sep 17 00:00:00 2001 From: Alexandre Gramfort Date: Sun, 28 Aug 2022 14:33:11 +0100 Subject: [PATCH 3/3] pydocstyle... --- mne/io/edf/tests/test_edf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mne/io/edf/tests/test_edf.py b/mne/io/edf/tests/test_edf.py index 39597923915..975059c328f 100644 --- a/mne/io/edf/tests/test_edf.py +++ b/mne/io/edf/tests/test_edf.py @@ -79,7 +79,6 @@ def test_orig_units(): def test_units_params(): """Test enforcing original channel units.""" - with pytest.raises(ValueError, match=r"Unit for channel .* is present .* Cannot " "overwrite it"):