mirror of
https://github.com/romanz/amodem.git
synced 2026-03-24 11:22:00 +08:00
common: enumerate -> index
This commit is contained in:
@@ -22,7 +22,7 @@ def dumps(sym):
|
|||||||
return sym.astype('int16').tostring()
|
return sym.astype('int16').tostring()
|
||||||
|
|
||||||
|
|
||||||
def iterate(data, size, func=None, truncate=True, enumerate=False):
|
def iterate(data, size, func=None, truncate=True, index=False):
|
||||||
offset = 0
|
offset = 0
|
||||||
data = iter(data)
|
data = iter(data)
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ def iterate(data, size, func=None, truncate=True, enumerate=False):
|
|||||||
done = True
|
done = True
|
||||||
|
|
||||||
result = func(buf) if func else np.array(buf)
|
result = func(buf) if func else np.array(buf)
|
||||||
yield (offset, result) if enumerate else result
|
yield (offset, result) if index else result
|
||||||
offset += size
|
offset += size
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Detector(object):
|
|||||||
def run(self, samples):
|
def run(self, samples):
|
||||||
counter = 0
|
counter = 0
|
||||||
bufs = collections.deque([], maxlen=self.maxlen)
|
bufs = collections.deque([], maxlen=self.maxlen)
|
||||||
for offset, buf in common.iterate(samples, self.Nsym, enumerate=True):
|
for offset, buf in common.iterate(samples, self.Nsym, index=True):
|
||||||
if offset > self.max_offset:
|
if offset > self.max_offset:
|
||||||
raise ValueError('Timeout waiting for carrier')
|
raise ValueError('Timeout waiting for carrier')
|
||||||
bufs.append(buf)
|
bufs.append(buf)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ def iterlist(x, *args, **kwargs):
|
|||||||
x = np.array(x)
|
x = np.array(x)
|
||||||
return list(
|
return list(
|
||||||
(i, list(x))
|
(i, list(x))
|
||||||
for i, x in common.iterate(x, enumerate=True, *args, **kwargs)
|
for i, x in common.iterate(x, index=True, *args, **kwargs)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user