Source code for oasislmf.utils.rounded_tqdm
from tqdm import tqdm
import math
# Hopefully remove when option is added to tqdm
[docs]
class rounded_tqdm(tqdm):
def __init__(self, *args, **kwargs):
kwargs.setdefault('bar_format', self.bar_format)
super().__init__(*args, **kwargs)
@property
[docs]
def format_dict(self):
d = super().format_dict
total = d.get('total')
n = d.get('n')
d['rounded_percent'] = math.floor(n / total * 100) if total else 0
return d