Files
pyRBM/src/rbm/status.py
T
2025-12-18 11:39:45 +01:00

29 lines
803 B
Python

class Status:
def __init__(self, update_interval=10):
self.progress = -1
self.update_interval = update_interval
@staticmethod
def print_status(status: dict):
print("-------------------------------------------")
for key in status.keys():
value = status[key]['value']
unit = status[key]['unit']
if isinstance(value, float):
print(f"{key} : {value:0.6f}{unit}")
else:
print(f"{key} : {value}{unit}")
def on_change(self, status: dict) -> bool:
do_continue = self.on_report(status=status)
return do_continue
def want_report(self, progress) -> bool:
if self.progress < 0 or progress - self.progress >= self.update_interval:
self.progress = progress
return True
return False
def on_report(self, status: dict) -> bool:
return True