Skip to content

Commit

Permalink
Use None instead of 'auto'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrnr authored and sappelhoff committed Mar 31, 2020
1 parent 5224a10 commit 1d8d8d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pybv/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def write_brainvision(data, sfreq, ch_names, fname_base, folder_out,
By default, this will be 1e-7, or 0.1 µV. This number controls the
amount of round-trip resolution. This can be either a single float for
all channels or an array with n_channels elements.
unit : str
unit : str | None
The unit of the exported data. This can be one of 'V', 'mV', 'µV' (or
equivalently 'uV') , 'nV' or 'auto'. If 'auto', a suitable unit based
on the selected resolution is chosen automatically.
equivalently 'uV') , 'nV' or None. If None, a suitable unit based on
the selected resolution is chosen automatically.
scale_data : bool
Boolean indicating if the data is in volts and should be scaled to
`resolution` (True), or if the data is already in the previously
Expand Down Expand Up @@ -208,7 +208,7 @@ def _write_vmrk_file(vmrk_fname, eeg_fname, events, meas_date):
def _optimize_channel_unit(resolution, unit):
"""Calculate an optimal channel scaling factor and unit."""
exp = np.log10(resolution)
if unit == 'auto':
if unit is None:
if exp <= -7:
return resolution / 1e-9, 'nV'
elif exp <= -2:
Expand Down
2 changes: 1 addition & 1 deletion pybv/tests/test_bv_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_scale_data():


@pytest.mark.parametrize("resolution", np.logspace(-3, -9, 7))
@pytest.mark.parametrize("unit", ["V", "mV", "uV", "µV", "nV"])
@pytest.mark.parametrize("unit", ["V", "mV", "uV", "µV", "nV", None])
def test_unit_resolution(resolution, unit):
"""Test different combinations of units and resolutions."""
tmpdir = _mktmpdir()
Expand Down

0 comments on commit 1d8d8d1

Please sign in to comment.