Use the "if not self.samplerate" form, which catches both the case
where self.samplerate is None, as well as the case where it is 0.
This is also consistent with all the other PDs.
)
def us2samples(self, us):
)
def us2samples(self, us):
- if self.samplerate is None:
+ if not self.samplerate:
raise Exception('Need the samplerate.')
return int(us * self.samplerate / 1000000)
raise Exception('Need the samplerate.')
return int(us * self.samplerate / 1000000)
self.put(es, ss, self.out_binary, (0, bytes(self.bits)))
def decode(self, ss, es, data):
self.put(es, ss, self.out_binary, (0, bytes(self.bits)))
def decode(self, ss, es, data):
- if self.samplerate is None:
+ if not self.samplerate:
raise Exception('Cannot decode without samplerate.')
for (self.samplenum, pins) in data:
# find edges ...
raise Exception('Cannot decode without samplerate.')
for (self.samplenum, pins) in data:
# find edges ...