-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyPTP.py
More file actions
32 lines (27 loc) · 1.06 KB
/
Copy pathpyPTP.py
File metadata and controls
32 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
### Process Time Printer Class
import time
import numpy as np
from numpy import random
class process_time_printer():
def __init__(self, count=None):
if count is not None:
self.count = count
else:
self.count = False
self.iteration = 1
self.time_list = []
self.start_time = time.time()
def increment(self, st):
self.time_list.append(self.get_time() - st)
if self.count == False:
print('| {0} complete | {1} seconds elapsed | '.format(
self.iteration, round(self.get_time() - self.start_time, 4)
), end='\r', flush=True)
else:
print('| {0}/{1} complete | {2} seconds elapsed | {3} estimated seconds remaining | '.format(
self.iteration, self.count, round(self.get_time() - self.start_time, 4)
, round((self.count - self.iteration) * np.mean(self.time_list), 4)
), end='\r', flush=True)
self.iteration += 1
def get_time(self):
return time.time()