Skip to content

Commit 03ea53e

Browse files
committed
remove redundant format check
1 parent 5021140 commit 03ea53e

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

wfdb/io/_header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def get_sig_name(self):
492492
if self.segments is None:
493493
raise Exception("The MultiRecord's segments must be read in before this method is called. ie. Call rdheader() with rd_segments=True")
494494

495-
if self.layout == 'Fixed':
495+
if self.layout == 'fixed':
496496
for i in range(self.n_seg):
497497
if self.seg_name[i] != '~':
498498
sig_name = self.segments[i].sig_name

wfdb/io/record.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from . import _signal
1919
from . import download
2020

21-
21+
import pdb
2222
class BaseRecord(object):
2323
# The base WFDB class extended by the Record and MultiRecord classes.
2424
def __init__(self, record_name=None, n_sig=None,
@@ -569,7 +569,7 @@ def checksegmentcohesion(self):
569569
def required_segments(self, sampfrom, sampto, channels):
570570

571571
# The starting segment with actual samples
572-
if self.layout == 'Fixed':
572+
if self.layout == 'fixed':
573573
startseg = 0
574574
else:
575575
startseg = 1
@@ -612,7 +612,7 @@ def required_segments(self, sampfrom, sampto, channels):
612612
def required_signal(self, readsegs, channels, dirname, pb_dir):
613613

614614
# Fixed layout. All channels are the same.
615-
if self.layout == 'Fixed':
615+
if self.layout == 'fixed':
616616
# Should we bother here with skipping empty segments?
617617
# They won't be read anyway.
618618
readsigs = [channels]*len(readsegs)
@@ -649,7 +649,7 @@ def arrange_fields(self, readsegs, segranges, channels):
649649

650650
# Get rid of the segments and segment line parameters
651651
# outside the desired segment range
652-
if self.layout == 'Fixed':
652+
if self.layout == 'fixed':
653653
self.segments = self.segments[readsegs[0]:readsegs[-1]+1]
654654
self.seg_name = self.seg_name[readsegs[0]:readsegs[-1]+1]
655655
self.seg_len = self.seg_len[readsegs[0]:readsegs[-1]+1]
@@ -703,7 +703,7 @@ def multi_to_single(self, return_res=64):
703703
startsamps = [0] + list(np.cumsum(self.seg_len)[0:-1])
704704
endsamps = list(np.cumsum(self.seg_len))
705705

706-
if self.layout == 'Fixed':
706+
if self.layout == 'fixed':
707707
# Get the signal names and units from the first segment
708708
fields['sig_name'] = self.segments[0].sig_name
709709
fields['units'] = self.segments[0].units
@@ -834,9 +834,9 @@ def rdheader(record_name, pb_dir=None, rd_segments=False):
834834
setattr(record, field, d_rec[field])
835835
# Determine whether the record is fixed or variable
836836
if record.seg_len[0] == 0:
837-
record.layout = 'Variable'
837+
record.layout = 'variable'
838838
else:
839-
record.layout = 'Fixed'
839+
record.layout = 'fixed'
840840

841841
# If specified, read the segment headers
842842
if rd_segments:
@@ -1000,14 +1000,9 @@ def rdrecord(record_name, sampfrom=0, sampto='end', channels='all',
10001000

10011001
record.segments = [None]*record.n_seg
10021002

1003-
# Variable layout
1004-
if record.seg_len[0] == 0:
1005-
record.layout = 'Variable'
1006-
# Read the layout specification header
1003+
# Variable layout, read the layout specification header
1004+
if record.layout == 'variable':
10071005
record.segments[0] = rdheader(os.path.join(dirname, record.seg_name[0]), pb_dir=pb_dir)
1008-
# Fixed layout
1009-
else:
1010-
record.layout = 'Fixed'
10111006

10121007
# The segment numbers and samples within each segment to read.
10131008
readsegs, segranges = record.required_segments(sampfrom, sampto, channels)

0 commit comments

Comments
 (0)