Skip to content

Commit 8f4fd87

Browse files
author
Benjamin Moody
committed
_rd_dat_signals: 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_dat_signals 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_dat_signals is _rd_segment, and the only caller of _rd_segment is wfdb.io.record.rdrecord.)
1 parent 0d41603 commit 8f4fd87

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
@@ -1089,7 +1089,7 @@ def _rd_dat_signals(file_name, dir_name, pn_dir, fmt, n_sig, sig_len,
10891089
sampto : int
10901090
The final sample number to be read from the signals.
10911091
smooth_frames : bool
1092-
Whether to smooth channels with multiple samples/frame.
1092+
Whether to return the result as a two-dimensional array.
10931093
no_file : bool, optional
10941094
Used when using this function with just an array of signal data
10951095
and no associated file to read the data from.
@@ -1101,9 +1101,8 @@ def _rd_dat_signals(file_name, dir_name, pn_dir, fmt, n_sig, sig_len,
11011101
-------
11021102
signal : ndarray, list
11031103
The signals read from the dat file(s). A 2d numpy array is
1104-
returned if the signals have uniform samples/frame or if
1105-
`smooth_frames` is True. Otherwise a list of 1d numpy arrays
1106-
is returned.
1104+
returned if `smooth_frames` is True. Otherwise a list of 1d
1105+
numpy arrays is returned.
11071106
11081107
Notes
11091108
-----
@@ -1212,7 +1211,7 @@ def _rd_dat_signals(file_name, dir_name, pn_dir, fmt, n_sig, sig_len,
12121211
# required for storing the final digital samples.
12131212

12141213
# No extra samples/frame. Obtain original uniform numpy array
1215-
if tsamps_per_frame == n_sig:
1214+
if smooth_frames and tsamps_per_frame == n_sig:
12161215
# Reshape into multiple channels
12171216
signal = sig_data.reshape(-1, n_sig)
12181217
# Skew the signal

0 commit comments

Comments
 (0)