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

Function test_sequence_decimal_infer

python/pyarrow/tests/test_convert_builtin.py:1711–1730  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1709
1710
1711def test_sequence_decimal_infer():
1712 for data, typ in [
1713 # simple case
1714 (decimal.Decimal('1.234'), pa.decimal128(4, 3)),
1715 # trailing zeros
1716 (decimal.Decimal('12300'), pa.decimal128(5, 0)),
1717 (decimal.Decimal('12300.0'), pa.decimal128(6, 1)),
1718 # scientific power notation
1719 (decimal.Decimal('1.23E+4'), pa.decimal128(5, 0)),
1720 (decimal.Decimal('123E+2'), pa.decimal128(5, 0)),
1721 (decimal.Decimal('123E+4'), pa.decimal128(7, 0)),
1722 # leading zeros
1723 (decimal.Decimal('0.0123'), pa.decimal128(4, 4)),
1724 (decimal.Decimal('0.01230'), pa.decimal128(5, 5)),
1725 (decimal.Decimal('1.230E-2'), pa.decimal128(5, 5)),
1726 ]:
1727 assert pa.infer_type([data]) == typ
1728 arr = pa.array([data])
1729 assert arr.type == typ
1730 assert arr.to_pylist()[0] == data
1731
1732
1733def test_sequence_decimal_infer_mixed():

Callers

nothing calls this directly

Calls 2

DecimalMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected