Skip to content

Commit

Permalink
fix res estimator
Browse files Browse the repository at this point in the history
  • Loading branch information
cx1111 committed Jun 22, 2018
1 parent 4a22256 commit d9f04c5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wfdb/io/_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,17 +1506,20 @@ def est_res(signals):
# Estimate the number of steps as the range divided by the
# minimum increment.
if isinstance(signals, list):
sortedsig = np.sort(signals[ch])
sorted_sig = np.sort(np.unique(signals[ch]))
else:
sortedsig = np.sort(signals[:,ch])
if signals.ndim == 1:
sorted_sig = np.sort(np.unique(signals))
else:
sorted_sig = np.sort(np.unique(signals[:,ch]))

min_inc = min(np.diff(sortedsig))
min_inc = min(np.diff(sorted_sig))

if min_inc == 0:
# Case where signal is flat. Resolution is 0.
res.append(0)
else:
nlevels = 1 + (sortedsig[-1]-sortedsig[0])/min_inc
nlevels = 1 + (sorted_sig[-1]-sorted_sig[0]) / min_inc
if nlevels >= res_levels[-1]:
res.append(32)
else:
Expand Down

0 comments on commit d9f04c5

Please sign in to comment.