From dc8eeedeb132e01943f4d13664b5b6e7831fc13a Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 25 Dec 2015 03:50:17 +0000 Subject: [PATCH] it/s versus s/it: addresses #72 --- tqdm/_tqdm.py | 9 +++++---- tqdm/tests/tests_tqdm.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index a31f5c4d..a48762cd 100644 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -119,10 +119,11 @@ def format_meter(n, total, elapsed, ncols=None, prefix='', ascii=False, # (we allow manual override since predicting time is an arcane art) if rate is None and elapsed: rate = n / elapsed - rate_fmt = ((format_sizeof(rate) if unit_scale else - '{0:5.2f}'.format(rate)) if elapsed else - '?') \ - + unit + '/s' + inv_rate = 1 / rate if (rate and (rate < 1)) else None + rate_fmt = ((format_sizeof(inv_rate if inv_rate else rate) if unit_scale + else '{0:5.2f}'.format(inv_rate if inv_rate else rate)) + if elapsed else '?') \ + + ('s' if inv_rate else unit) + '/' + (unit if inv_rate else 's') if unit_scale: n_fmt = format_sizeof(n) diff --git a/tqdm/tests/tests_tqdm.py b/tqdm/tests/tests_tqdm.py index c18324e7..84ea1a8e 100644 --- a/tqdm/tests/tests_tqdm.py +++ b/tqdm/tests/tests_tqdm.py @@ -56,12 +56,12 @@ def test_format_meter(): "desc: 0%| | 0/1000 [00:13