Skip to content

Commit f2b8ab6

Browse files
author
Benjamin Moody
committed
_rd_segment: reformat for readability/maintainability.
In each branch, the calls to _rd_dat_signals with and without 'no_file=True, sig_data=sig_data' were otherwise identical. sig_data is ignored if no_file is false, so this is equivalent to simply passing 'no_file=no_file, sig_data=sig_data'. Furthermore, since _rd_dat_signals takes a huge number of arguments, convert all of them to keyword style to avoid confusion.
1 parent f6e5179 commit f2b8ab6

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

wfdb/io/_signal.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -997,17 +997,22 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
997997

998998
# Read each wanted dat file and store signals
999999
for fn in w_file_name:
1000-
if no_file:
1001-
signals[:, out_dat_channel[fn]] = _rd_dat_signals(fn, dir_name,
1002-
pn_dir, w_fmt[fn], len(datchannel[fn]), sig_len,
1003-
w_byte_offset[fn], w_samps_per_frame[fn], w_skew[fn],
1004-
sampfrom, sampto, smooth_frames, no_file=True,
1005-
sig_data=sig_data)[:, r_w_channel[fn]]
1006-
else:
1007-
signals[:, out_dat_channel[fn]] = _rd_dat_signals(fn, dir_name,
1008-
pn_dir, w_fmt[fn], len(datchannel[fn]), sig_len,
1009-
w_byte_offset[fn], w_samps_per_frame[fn], w_skew[fn],
1010-
sampfrom, sampto, smooth_frames)[:, r_w_channel[fn]]
1000+
datsignals = _rd_dat_signals(
1001+
file_name=fn,
1002+
dir_name=dir_name,
1003+
pn_dir=pn_dir,
1004+
fmt=w_fmt[fn],
1005+
n_sig=len(datchannel[fn]),
1006+
sig_len=sig_len,
1007+
byte_offset=w_byte_offset[fn],
1008+
samps_per_frame=w_samps_per_frame[fn],
1009+
skew=w_skew[fn],
1010+
sampfrom=sampfrom,
1011+
sampto=sampto,
1012+
smooth_frames=smooth_frames,
1013+
no_file=no_file,
1014+
sig_data=sig_data)
1015+
signals[:, out_dat_channel[fn]] = datsignals[:, r_w_channel[fn]]
10111016

10121017
# Return each sample in signals with multiple samples/frame, without smoothing.
10131018
# Return a list of numpy arrays for each signal.
@@ -1016,16 +1021,21 @@ def _rd_segment(file_name, dir_name, pn_dir, fmt, n_sig, sig_len, byte_offset,
10161021

10171022
for fn in w_file_name:
10181023
# Get the list of all signals contained in the dat file
1019-
if no_file:
1020-
datsignals = _rd_dat_signals(fn, dir_name, pn_dir, w_fmt[fn],
1021-
len(datchannel[fn]), sig_len, w_byte_offset[fn],
1022-
w_samps_per_frame[fn], w_skew[fn], sampfrom, sampto,
1023-
smooth_frames, no_file=True, sig_data=sig_data)
1024-
else:
1025-
datsignals = _rd_dat_signals(fn, dir_name, pn_dir, w_fmt[fn],
1026-
len(datchannel[fn]), sig_len, w_byte_offset[fn],
1027-
w_samps_per_frame[fn], w_skew[fn], sampfrom, sampto,
1028-
smooth_frames)
1024+
datsignals = _rd_dat_signals(
1025+
file_name=fn,
1026+
dir_name=dir_name,
1027+
pn_dir=pn_dir,
1028+
fmt=w_fmt[fn],
1029+
n_sig=len(datchannel[fn]),
1030+
sig_len=sig_len,
1031+
byte_offset=w_byte_offset[fn],
1032+
samps_per_frame=w_samps_per_frame[fn],
1033+
skew=w_skew[fn],
1034+
sampfrom=sampfrom,
1035+
sampto=sampto,
1036+
smooth_frames=smooth_frames,
1037+
no_file=no_file,
1038+
sig_data=sig_data)
10291039

10301040
# Copy over the wanted signals
10311041
for cn in range(len(out_dat_channel[fn])):

0 commit comments

Comments
 (0)