MCPcopy Create free account
hub / github.com/apache/arrow / random_float_to_decimal_cast_cases

Function random_float_to_decimal_cast_cases

python/pyarrow/tests/test_compute.py:2215–2226  ·  view source on GitHub ↗

Return random-generated FloatToDecimalCase instances.

(float_ty, max_precision)

Source from the content-addressed store, hash-verified

2213
2214
2215def random_float_to_decimal_cast_cases(float_ty, max_precision):
2216 """
2217 Return random-generated FloatToDecimalCase instances.
2218 """
2219 r = random.Random(42)
2220 for precision in range(1, max_precision, 6):
2221 for scale in range(0, precision, 4):
2222 for i in range(20):
2223 unscaled = r.randrange(0, 10**precision)
2224 float_val = scaled_float(unscaled, scale)
2225 assert float_val * 10**scale < 10**precision
2226 yield FloatToDecimalCase(precision, scale, float_val)
2227
2228
2229def check_cast_float_to_decimal(float_ty, float_val, decimal_ty, decimal_ctx,

Callers

nothing calls this directly

Calls 2

scaled_floatFunction · 0.85
RandomMethod · 0.45

Tested by

no test coverage detected