MCPcopy Create free account
hub / github.com/imrahulr/hat / str2float

Function str2float

core/utils/utils.py:63–74  ·  view source on GitHub ↗

Parse float and fractions using argument parser.

(x)

Source from the content-addressed store, hash-verified

61 raise argparse.ArgumentTypeError('Boolean value expected.')
62
63def str2float(x):
64 """
65 Parse float and fractions using argument parser.
66 """
67 if '/' in x:
68 n, d = x.split('/')
69 return float(n)/float(d)
70 else:
71 try:
72 return float(x)
73 except:
74 raise argparse.ArgumentTypeError('Fraction or float value expected.')
75
76
77def format_time(elapsed):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…