Merging upstream version 4.66.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-05 19:14:31 +01:00
parent ec03e12832
commit 6759e100fe
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
61 changed files with 917 additions and 4364 deletions

View file

@ -1,5 +1,3 @@
from __future__ import division, print_function
import sys
from contextlib import contextmanager
from functools import wraps
@ -14,7 +12,7 @@ except ImportError:
from tqdm import tqdm, trange
from .tests_tqdm import _range, importorskip, mark, patch_lock, skip
from .tests_tqdm import importorskip, mark, patch_lock, skip
pytestmark = mark.slow
@ -98,10 +96,7 @@ def simple_progress(iterable=None, total=None, file=sys.stdout, desc='',
def format_interval(t):
mins, s = divmod(int(t), 60)
h, m = divmod(mins, 60)
if h:
return '{0:d}:{1:02d}:{2:02d}'.format(h, m, s)
else:
return '{0:02d}:{1:02d}'.format(m, s)
return f'{h:d}:{m:02d}:{s:02d}' if h else f'{m:02d}:{s:02d}'
def update_and_print(i=1):
n[0] += i
@ -143,20 +138,15 @@ def simple_progress(iterable=None, total=None, file=sys.stdout, desc='',
update_and_print(0)
if iterable is not None:
return update_and_yield()
else:
return update_and_print
return update_and_print
def assert_performance(thresh, name_left, time_left, name_right, time_right):
"""raises if time_left > thresh * time_right"""
if time_left > thresh * time_right:
raise ValueError(
('{name[0]}: {time[0]:f}, '
'{name[1]}: {time[1]:f}, '
'ratio {ratio:f} > {thresh:f}').format(
name=(name_left, name_right),
time=(time_left, time_right),
ratio=time_left / time_right, thresh=thresh))
f'{name_left}: {time_left:f}, {name_right}: {time_right:f}'
f', ratio {time_left / time_right:f} > {thresh:f}')
@retry_on_except()
@ -173,7 +163,7 @@ def test_iter_basic_overhead():
a = 0
with relative_timer() as time_bench:
for i in _range(total):
for i in range(total):
a += i
sys.stdout.write(str(a))
@ -188,13 +178,13 @@ def test_manual_basic_overhead():
with tqdm(total=total * 10, leave=True) as t:
a = 0
with relative_timer() as time_tqdm:
for i in _range(total):
for i in range(total):
a += i
t.update(10)
a = 0
with relative_timer() as time_bench:
for i in _range(total):
for i in range(total):
a += i
sys.stdout.write(str(a))
@ -249,7 +239,7 @@ def test_iter_overhead_hard():
a = 0
with relative_timer() as time_bench:
for i in _range(total):
for i in range(total):
a += i
sys.stdout.write(("%i" % a) * 40)
@ -265,13 +255,13 @@ def test_manual_overhead_hard():
mininterval=0, maxinterval=0) as t:
a = 0
with relative_timer() as time_tqdm:
for i in _range(total):
for i in range(total):
a += i
t.update(10)
a = 0
with relative_timer() as time_bench:
for i in _range(total):
for i in range(total):
a += i
sys.stdout.write(("%i" % a) * 40)
@ -292,7 +282,7 @@ def test_iter_overhead_simplebar_hard():
assert a == (total ** 2 - total) / 2.0
a = 0
s = simple_progress(_range(total), leave=True,
s = simple_progress(range(total), leave=True,
miniters=1, mininterval=0)
with relative_timer() as time_bench:
for i in s:
@ -310,7 +300,7 @@ def test_manual_overhead_simplebar_hard():
mininterval=0, maxinterval=0) as t:
a = 0
with relative_timer() as time_tqdm:
for i in _range(total):
for i in range(total):
a += i
t.update(10)
@ -318,7 +308,7 @@ def test_manual_overhead_simplebar_hard():
miniters=1, mininterval=0)
a = 0
with relative_timer() as time_bench:
for i in _range(total):
for i in range(total):
a += i
simplebar_update(10)