mirror of https://github.com/tqdm/tqdm.git
parent
a774e3ff8d
commit
42de6bdfc9
10
tqdm/std.py
10
tqdm/std.py
|
@ -10,7 +10,7 @@ Usage:
|
||||||
from __future__ import absolute_import, division
|
from __future__ import absolute_import, division
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict, defaultdict
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from numbers import Number
|
from numbers import Number
|
||||||
|
@ -1420,14 +1420,16 @@ class tqdm(Comparable):
|
||||||
@property
|
@property
|
||||||
def format_dict(self):
|
def format_dict(self):
|
||||||
"""Public API for read-only member access."""
|
"""Public API for read-only member access."""
|
||||||
|
if self.disable and not hasattr(self, 'unit'):
|
||||||
|
return defaultdict(lambda: None, {
|
||||||
|
'n': self.n, 'total': self.total, 'elapsed': 0, 'unit': 'it'})
|
||||||
if self.dynamic_ncols:
|
if self.dynamic_ncols:
|
||||||
self.ncols, self.nrows = self.dynamic_ncols(self.fp)
|
self.ncols, self.nrows = self.dynamic_ncols(self.fp)
|
||||||
ncols, nrows = self.ncols, self.nrows
|
|
||||||
return {
|
return {
|
||||||
'n': self.n, 'total': self.total,
|
'n': self.n, 'total': self.total,
|
||||||
'elapsed': self._time() - self.start_t if hasattr(self, 'start_t') else 0,
|
'elapsed': self._time() - self.start_t if hasattr(self, 'start_t') else 0,
|
||||||
'ncols': ncols, 'nrows': nrows, 'prefix': self.desc, 'ascii': self.ascii,
|
'ncols': self.ncols, 'nrows': self.nrows, 'prefix': self.desc,
|
||||||
'unit': self.unit, 'unit_scale': self.unit_scale,
|
'ascii': self.ascii, 'unit': self.unit, 'unit_scale': self.unit_scale,
|
||||||
'rate': self._ema_dn() / self._ema_dt() if self._ema_dt() else None,
|
'rate': self._ema_dn() / self._ema_dt() if self._ema_dt() else None,
|
||||||
'bar_format': self.bar_format, 'postfix': self.postfix,
|
'bar_format': self.bar_format, 'postfix': self.postfix,
|
||||||
'unit_divisor': self.unit_divisor, 'initial': self.initial,
|
'unit_divisor': self.unit_divisor, 'initial': self.initial,
|
||||||
|
|
Loading…
Reference in New Issue