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

Function test_decimal128

python/pyarrow/tests/test_scalars.py:266–281  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

264
265
266def test_decimal128():
267 v = decimal.Decimal("1.123")
268 s = pa.scalar(v)
269 assert isinstance(s, pa.Decimal128Scalar)
270 assert s.as_py() == v
271 assert s.type == pa.decimal128(4, 3)
272
273 v = decimal.Decimal("1.1234")
274 with pytest.raises(pa.ArrowInvalid):
275 pa.scalar(v, type=pa.decimal128(4, scale=3))
276 with pytest.raises(pa.ArrowInvalid):
277 pa.scalar(v, type=pa.decimal128(5, scale=3))
278
279 s = pa.scalar(v, type=pa.decimal128(5, scale=4))
280 assert isinstance(s, pa.Decimal128Scalar)
281 assert s.as_py() == v
282
283
284def test_decimal256():

Callers

nothing calls this directly

Calls 3

as_pyMethod · 0.80
DecimalMethod · 0.45
scalarMethod · 0.45

Tested by

no test coverage detected