Skip to content

Commit 426f52a

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 64614de commit 426f52a

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
@@ -897,7 +897,7 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
897897
sampto : int
898898
The final sample number to be read from the signals.
899899
smooth_frames : bool
900-
Whether to smooth channels with multiple samples/frame.
900+
Whether to return the result as a two-dimensional array.
901901
ignore_skew : bool
902902
Used when reading records with at least one skewed signal.
903903
Specifies whether to apply the skew to align the signals in the
@@ -919,9 +919,8 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
919919
-------
920920
signals : ndarray, list
921921
The signals read from the dat file(s). A 2d numpy array is
922-
returned if the signals have uniform samples/frame or if
923-
`smooth_frames` is True. Otherwise a list of 1d numpy arrays
924-
is returned.
922+
returned if `smooth_frames` is True. Otherwise a list of 1d
923+
numpy arrays is returned.
925924
926925
Notes
927926
-----
@@ -988,7 +987,7 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
988987

989988
# Signals with multiple samples/frame are smoothed, or all signals have 1 sample/frame.
990989
# Return uniform numpy array
991-
if smooth_frames or sum(samps_per_frame) == n_sig:
990+
if smooth_frames:
992991
# Figure out the largest required dtype for the segment to minimize memory usage
993992
max_dtype = _np_dtype(_fmt_res(fmt, max_res=True), discrete=True)
994993
# Allocate signal array. Minimize dtype

0 commit comments

Comments
 (0)