mirror of https://github.com/tqdm/tqdm.git
parent
1305eacbee
commit
05dc6d5011
|
@ -27,6 +27,7 @@ def format_sizeof(num, suffix='bytes'):
|
||||||
num /= 1000.0
|
num /= 1000.0
|
||||||
return "%.1f%s%s" % (num, 'Y', suffix)
|
return "%.1f%s%s" % (num, 'Y', suffix)
|
||||||
|
|
||||||
|
|
||||||
def format_interval(t):
|
def format_interval(t):
|
||||||
mins, s = divmod(int(t), 60)
|
mins, s = divmod(int(t), 60)
|
||||||
h, m = divmod(mins, 60)
|
h, m = divmod(mins, 60)
|
||||||
|
@ -36,7 +37,8 @@ def format_interval(t):
|
||||||
return '{0:02d}:{1:02d}'.format(m, s)
|
return '{0:02d}:{1:02d}'.format(m, s)
|
||||||
|
|
||||||
|
|
||||||
def format_meter(n, total, elapsed, ncols=None, prefix='', unit=None, unit_scale=False, ascii=False):
|
def format_meter(n, total, elapsed, ncols=None, prefix='', \
|
||||||
|
unit=None, unit_scale=False, ascii=False):
|
||||||
"""
|
"""
|
||||||
Return a string-based progress bar given some parameters
|
Return a string-based progress bar given some parameters
|
||||||
|
|
||||||
|
@ -59,9 +61,10 @@ def format_meter(n, total, elapsed, ncols=None, prefix='', unit=None, unit_scale
|
||||||
String that will be used to define the unit of each iteration.
|
String that will be used to define the unit of each iteration.
|
||||||
[default: "it"]
|
[default: "it"]
|
||||||
unit_scale : bool, optional
|
unit_scale : bool, optional
|
||||||
If set, the number of iterations will be reduced/scaled automatically
|
If set, the number of iterations will be reduced/scaled
|
||||||
and a metric prefix following the International System of Units standard
|
automatically and a metric prefix following the
|
||||||
will be added (kilo, mega, etc.). [default: False]
|
International System of Units standard will be added
|
||||||
|
(kilo, mega, etc.). [default: False]
|
||||||
ascii : bool, optional
|
ascii : bool, optional
|
||||||
If not set, use unicode (smooth blocks) to fill the meter
|
If not set, use unicode (smooth blocks) to fill the meter
|
||||||
[default: False]. The fallback is to use ASCII characters (1-9 #).
|
[default: False]. The fallback is to use ASCII characters (1-9 #).
|
||||||
|
@ -70,7 +73,10 @@ def format_meter(n, total, elapsed, ncols=None, prefix='', unit=None, unit_scale
|
||||||
-------
|
-------
|
||||||
out : Formatted meter and stats, ready to display.
|
out : Formatted meter and stats, ready to display.
|
||||||
"""
|
"""
|
||||||
if total and n > total: # in case the total is wrong (n is above the total), then we switch to the mode without showing the total prediction (since ETA would be wrong anyway)
|
|
||||||
|
# in case the total is wrong (n is above the total), then we switch to the mode without showing
|
||||||
|
# the total prediction (since ETA would be wrong anyway)
|
||||||
|
if total and n > total:
|
||||||
total = None
|
total = None
|
||||||
|
|
||||||
elapsed_str = format_interval(elapsed)
|
elapsed_str = format_interval(elapsed)
|
||||||
|
@ -184,9 +190,10 @@ class tqdm(object):
|
||||||
String that will be used to define the unit of each iteration.
|
String that will be used to define the unit of each iteration.
|
||||||
[default: "it"]
|
[default: "it"]
|
||||||
unit_scale : bool, optional
|
unit_scale : bool, optional
|
||||||
If set, the number of iterations will be reduced/scaled automatically
|
If set, the number of iterations will be reduced/scaled
|
||||||
and a metric prefix following the International System of Units standard
|
automatically and a metric prefix following the
|
||||||
will be added (kilo, mega, etc.). [default: False]
|
International System of Units standard will be added
|
||||||
|
(kilo, mega, etc.). [default: False]
|
||||||
ascii : bool, optional
|
ascii : bool, optional
|
||||||
If not set, use unicode (smooth blocks) to fill the meter
|
If not set, use unicode (smooth blocks) to fill the meter
|
||||||
[default: False]. The fallback is to use ASCII characters (1-9 #).
|
[default: False]. The fallback is to use ASCII characters (1-9 #).
|
||||||
|
|
Loading…
Reference in New Issue