Skip to content

Commit

Permalink
Update highlevel.py
Browse files Browse the repository at this point in the history
Converted assert's into warnings. Reason:

in some cases, storing an edf file fails because of roundoff errors:
e.g. `phys_min -3565.82 vs. signal_min 3565.8200000000000006` will fail in write_edf (but shouldn't)
  • Loading branch information
TrianecT-Wouter authored Dec 11, 2024
1 parent ea9ee94 commit f7eb141
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyedflib/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ def write_edf(
assert pmin != pmax, \
f'physical_min {pmin} should be different from physical_max {pmax}'
else: # only warning, as this will not lead to clipping
assert pmin<=sig.min(), \
'phys_min is {}, but signal_min is {} ' \
'for channel {}'.format(pmin, sig.min(), label)
assert pmax>=sig.max(), \
'phys_max is {}, but signal_max is {} ' \
'for channel {}'.format(pmax, sig.max(), label)
if pmin > sig.min():
warnings.warn(f'phys_min is {pmin}, but signal_min is {sig.min()} ' \
'for channel {label}')
if pmax < sig.max():
warnings.warn(f'phys_max is {pmax}, but signal_max is {sig.max()} ' \
'for channel {label}')

# get annotations, in format [[timepoint, duration, description], [...]]
annotations = header.get('annotations', [])
Expand Down

0 comments on commit f7eb141

Please sign in to comment.