Commit 8ad55f2a authored by augustin_s's avatar augustin_s 🐍
Browse files

moved modified tqdm into separate utils file

parent df6e4302
......@@ -2,12 +2,11 @@ import requests
import json
from glob import glob
from time import sleep
from tqdm import tqdm
from yaspin import yaspin
from yaspin.spinners import Spinners
import numpy as np
from slic.utils import xrange
from slic.utils import xrange, tqdm_mod, tqdm_sleep
from slic.utils.json import json_validate
from .broker_tools import get_current_pulseid
......@@ -93,7 +92,7 @@ class BrokerClient:
self.running = True
with stqdm(total=n_pulses) as pbar:
with tqdm_mod(total=n_pulses) as pbar:
while self.running:
current_pulseid = get_current_pulseid()
delta_n = (current_pulseid - start_pulseid) // rate_multiplicator
......@@ -332,32 +331,6 @@ def align_pid(pid, rm, block_offset=0):
class stqdm(tqdm):
def set(self, elapsed):
"""
update with elapsed n, i.e., the delta between start and current n
"""
elapsed = clamp(elapsed, 0, self.total)
increment = elapsed - self.n
self.update(increment)
def clamp(val, vmin, vmax):
val = max(val, vmin)
val = min(val, vmax)
return val
def tqdm_sleep(seconds, ndiv=100):
delta = seconds / float(ndiv)
for _ in tqdm(range(ndiv)):
sleep(delta)
def wait_for_files(label, fnames):
with yaspin(Spinners.clock, text=f"elapsed time: {label}", timer=True) as sp:
while True:
......
......@@ -16,6 +16,7 @@ from .readable import readable_seconds
from .screenshot import Screenshot
from .shortcut import Shortcut, shortcuts, as_shortcut
from .snapshot import snapshot
from .tqdm_mod import tqdm_mod, tqdm_sleep
from .xrange import xrange
from time import sleep
import tqdm
class tqdm_mod(tqdm.tqdm):
def set(self, elapsed):
"""
update with elapsed n, i.e., the delta between start and current n
"""
elapsed = clamp(elapsed, 0, self.total)
increment = elapsed - self.n
self.update(increment)
def clamp(val, vmin, vmax):
val = max(val, vmin)
val = min(val, vmax)
return val
def tqdm_sleep(seconds, ndiv=100):
delta = seconds / float(ndiv)
for _ in tqdm.tqdm(range(ndiv)):
sleep(delta)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment