Skip to content

Commit 3e84119

Browse files
author
Benjamin Moody
committed
_rd_segment: always honor the smooth_frames parameter.
This function can return signal data in either of two formats: - "smooth" (a two-dimensional array, where x[t,s] is sample t of signal s) - "non-smooth" (a list of one-dimensional arrays, where x[s][t] is sample t of signal s) Previously, _rd_segment would use "smooth" format if 'sum(samps_per_frame) == n_sig', regardless of 'smooth_frames'. This makes little sense, since the caller needs to know what type of return value to expect. Instead, the format should be determined solely by the 'smooth_frames' parameter. (In this case, the only caller of _rd_segment is wfdb.io.record.rdrecord.)
1 parent 8f4fd87 commit 3e84119

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

wfdb/io/_signal.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
900900
sampto : int
901901
The final sample number to be read from the signals.
902902
smooth_frames : bool
903-
Whether to smooth channels with multiple samples/frame.
903+
Whether to return the result as a two-dimensional array.
904904
ignore_skew : bool
905905
Used when reading records with at least one skewed signal.
906906
Specifies whether to apply the skew to align the signals in the
@@ -922,9 +922,8 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
922922
-------
923923
signals : ndarray, list
924924
The signals read from the dat file(s). A 2d numpy array is
925-
returned if the signals have uniform samples/frame or if
926-
`smooth_frames` is True. Otherwise a list of 1d numpy arrays
927-
is returned.
925+
returned if `smooth_frames` is True. Otherwise a list of 1d
926+
numpy arrays is returned.
928927
929928
Notes
930929
-----
@@ -996,7 +995,7 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
996995

997996
# Signals with multiple samples/frame are smoothed, or all signals have 1 sample/frame.
998997
# Return uniform numpy array
999-
if smooth_frames or sum(samps_per_frame) == n_sig:
998+
if smooth_frames:
1000999
# Figure out the largest required dtype for the segment to minimize memory usage
10011000
max_dtype = _np_dtype(_fmt_res(fmt, max_res=True), discrete=True)
10021001
# Allocate signal array. Minimize dtype

0 commit comments

Comments
 (0)