Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for edf units param #11105

Merged
merged 3 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mne/io/edf/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was actually a bug ...

raise ValueError(f'Unit for channel {this_ch} is present in '
'the file. Cannot overwrite it with the '
'units argument.')
Expand Down
9 changes: 9 additions & 0 deletions mne/io/edf/tests/test_edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

hoechenberger marked this conversation as resolved.
Show resolved Hide resolved
with pytest.raises(ValueError,
match=r"Unit for channel .* is present .* Cannot "
"overwrite it"):
_ = 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)
Expand Down