Skip to content

Commit 8f9b848

Browse files
committed
code cleanup
1 parent bd0f75a commit 8f9b848

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/ppk2_api/ppk2_api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,14 @@ def __init__(self, ppk2, quit_evt, buffer_len_s=10, buffer_chunk_s=0.5):
362362
self._stats = (None, None)
363363
self._last_timestamp = 0
364364

365-
self._buffer_max_len = int(buffer_len_s*100000*4) # 100k 4-byte samples per second
366-
self._buffer_chunk = int(buffer_chunk_s*100000*4) # put in the queue in chunks of 0.5s
365+
self._buffer_max_len = int(buffer_len_s * 100000 * 4) # 100k 4-byte samples per second
366+
self._buffer_chunk = int(buffer_chunk_s * 100000 * 4) # put in the queue in chunks of 0.5s
367367

368368
# round buffers to a whole sample
369-
if self._buffer_max_len%4!=0:
370-
self._buffer_max_len = (self._buffer_max_len//4)*4
371-
if self._buffer_chunk%4!=0:
372-
self._buffer_chunk = (self._buffer_chunk//4)*4
369+
if self._buffer_max_len % 4 != 0:
370+
self._buffer_max_len = (self._buffer_max_len // 4) * 4
371+
if self._buffer_chunk % 4 != 0:
372+
self._buffer_chunk = (self._buffer_chunk // 4) * 4
373373

374374
self._buffer_q = multiprocessing.Queue()
375375

@@ -381,7 +381,7 @@ def run(self):
381381
d = PPK2_API.get_data(self._ppk2)
382382
tm_now = time.time()
383383
local_buffer += d
384-
while len(local_buffer)>=self._buffer_chunk:
384+
while len(local_buffer) >= self._buffer_chunk:
385385
# FIXME: check if lock might be needed when discarding old data
386386
self._buffer_q.put(local_buffer[:self._buffer_chunk])
387387
while self._buffer_q.qsize()>self._buffer_max_len/self._buffer_chunk:
@@ -392,8 +392,8 @@ def run(self):
392392

393393
# calculate stats
394394
s += len(d)
395-
dt = tm_now-t
396-
if dt>=1.0:
395+
dt = tm_now - t
396+
if dt >= 1.0:
397397
if self.print_stats:
398398
print(s, dt)
399399
self._stats = (s, dt)
@@ -425,7 +425,7 @@ class PPK2_MP(PPK2_API):
425425
Multiprocessing variant of the object. The interface is the same as for the regular one except it spawns
426426
a background process on start_measuring()
427427
'''
428-
def __init__(self, port, buffer_seconds=10, buffer_chunk_seconds=0.5):
428+
def __init__(self, port, buffer_seconds=10):
429429
'''
430430
port - port where PPK2 is connected
431431
buffer_seconds - how many seconds of data to keep in the buffer

0 commit comments

Comments
 (0)