@@ -26,6 +26,7 @@ def __init__(
26
26
self ,
27
27
count : int = 0 ,
28
28
total : int = None ,
29
+ start_count : int = 0 ,
29
30
head : str = "" ,
30
31
desc : str = "" ,
31
32
cols : int = 35 ,
@@ -42,6 +43,7 @@ def __init__(
42
43
):
43
44
self .count = count
44
45
self .total = total
46
+ self .start_count = start_count
45
47
self .head = head
46
48
self .desc = desc
47
49
self .cols = cols
@@ -72,6 +74,9 @@ def is_num(self, num: Union[int, float]):
72
74
def is_grouped (self ):
73
75
return self .group is not None and self .node_idx is not None
74
76
77
+ def elapsed_count (self ):
78
+ return self .count - self .start_count
79
+
75
80
def move_cursor (self ):
76
81
self .cursor .move (row = self .line_height - 1 )
77
82
self .cursor .erase_line ()
@@ -162,17 +167,21 @@ def update(
162
167
elif (
163
168
self .is_num (self .total )
164
169
and self .is_num (self .count )
165
- and self .count > 0
166
- and self .total - self .count >= 0
170
+ and self .elapsed_count () > 0
171
+ and self .total - self .elapsed_count () >= 0
167
172
):
168
173
self .remain_seconds = (
169
- dt_seconds * (self .total - self .count ) / self .count
174
+ dt_seconds
175
+ * (self .total - self .elapsed_count ())
176
+ / self .elapsed_count ()
170
177
)
171
178
else :
172
179
self .remain_seconds = None
173
180
174
181
if self .is_num (self .count ) and self .count > 0 and dt_seconds > 0 :
175
- self .iter_per_second = round (self .count / dt_seconds , ndigits = 1 )
182
+ self .iter_per_second = round (
183
+ self .elapsed_count () / dt_seconds , ndigits = 1
184
+ )
176
185
else :
177
186
self .iter_per_second = None
178
187
@@ -308,6 +317,9 @@ def set_total(self, total: int = None):
308
317
def set_count (self , count : int = None ):
309
318
self .count = count
310
319
320
+ def set_start_count (self , start_count : int = None ):
321
+ self .start_count = start_count
322
+
311
323
def increment (self , increment : int = None ):
312
324
self .count += increment
313
325
0 commit comments