MCPcopy Create free account
hub / github.com/apache/singa / update_progress

Function update_progress

python/singa/utils.py:27–53  ·  view source on GitHub ↗

Display progress bar and user info. Args: progress (float): progress [0, 1], negative for halt, and >=1 for done. info (str): a string for user provided info to be displayed.

(progress, info)

Source from the content-addressed store, hash-verified

25
26
27def update_progress(progress, info):
28 """Display progress bar and user info.
29
30 Args:
31 progress (float): progress [0, 1], negative for halt, and >=1 for done.
32 info (str): a string for user provided info to be displayed.
33 """
34 barLength = 20 # bar length
35 status = ""
36 if isinstance(progress, int):
37 progress = float(progress)
38 if not isinstance(progress, float):
39 progress = 0
40 status = "error: progress var must be float. "
41 if progress < 0:
42 progress = 0
43 status = "Halt. "
44 if progress >= 1:
45 progress = 1
46 status = "Done. "
47 status = status + info
48 block = int(round(barLength * progress))
49 text = "[{0}] {1:3.1f}% {2}".format("." * block + " " * (barLength - block),
50 progress * 100, status)
51 sys.stdout.write(text)
52 sys.stdout.write('\b' * (9 + barLength + len(status)))
53 sys.stdout.flush()
54
55
56def handle_odd_pad_fwd(x, odd_padding, is_pool=False):

Callers

nothing calls this directly

Calls 2

writeMethod · 0.80
roundFunction · 0.70

Tested by

no test coverage detected