MCPcopy Index your code
hub / github.com/python/cpython / randtuple

Function randtuple

Modules/_decimal/tests/randdec.py:131–144  ·  view source on GitHub ↗
(maxprec, maxexp)

Source from the content-addressed store, hash-verified

129 return randrange(10**(n-1), 10**n)
130
131def randtuple(maxprec, maxexp):
132 n = randrange(100)
133 sign = randrange(2)
134 coeff = ndigits(maxprec)
135 if n >= 95:
136 coeff = ()
137 exp = 'F'
138 elif n >= 85:
139 coeff = tuple(map(int, str(ndigits(maxprec))))
140 exp = "nN"[randrange(2)]
141 else:
142 coeff = tuple(map(int, str(ndigits(maxprec))))
143 exp = randrange(-maxexp, maxexp)
144 return (sign, coeff, exp)
145
146def from_triple(sign, coeff, exp):
147 return ''.join((str(sign*coeff), indicator(), str(exp)))

Callers 1

all_unaryFunction · 0.85

Calls 2

ndigitsFunction · 0.85
strFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…