MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _convert

Function _convert

tools/python-3.11.9-amd64/Lib/statistics.py:333–348  ·  view source on GitHub ↗

Convert value to given numeric type T.

(value, T)

Source from the content-addressed store, hash-verified

331
332
333def _convert(value, T):
334 """Convert value to given numeric type T."""
335 if type(value) is T:
336 # This covers the cases where T is Fraction, or where value is
337 # a NAN or INF (Decimal or float).
338 return value
339 if issubclass(T, int) and value.denominator != 1:
340 T = float
341 try:
342 # FIXME: what do we do if this overflows?
343 return T(value)
344 except TypeError:
345 if issubclass(T, Decimal):
346 return T(value.numerator) / T(value.denominator)
347 else:
348 raise
349
350
351def _fail_neg(values, errmsg='negative value'):

Callers 4

meanFunction · 0.70
harmonic_meanFunction · 0.70
varianceFunction · 0.70
pvarianceFunction · 0.70

Calls 2

typeClass · 0.50
TFunction · 0.50

Tested by

no test coverage detected