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

Function test_decimal_to_int_non_integer

python/pyarrow/tests/test_array.py:1833–1865  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1831
1832
1833def test_decimal_to_int_non_integer():
1834 non_integer_cases = [
1835 (
1836 [
1837 decimal.Decimal("123456.21"),
1838 None,
1839 decimal.Decimal("-912345.13")
1840 ],
1841 pa.decimal128(32, 5),
1842 [123456, None, -912345],
1843 pa.int32()
1844 ),
1845 (
1846 [decimal.Decimal("1234.134"), None, decimal.Decimal("-9123.1")],
1847 pa.decimal128(19, 10),
1848 [1234, None, -9123],
1849 pa.int16()
1850 ),
1851 (
1852 [decimal.Decimal("123.1451"), None, decimal.Decimal("-91.21")],
1853 pa.decimal128(19, 10),
1854 [123, None, -91],
1855 pa.int8()
1856 ),
1857 ]
1858
1859 for case in non_integer_cases:
1860 # test safe casting raises
1861 msg_regexp = 'Rescaling Decimal value would cause data loss'
1862 with pytest.raises(pa.ArrowInvalid, match=msg_regexp):
1863 _check_cast_case(case)
1864
1865 _check_cast_case(case, safe=False)
1866
1867
1868def test_decimal_to_decimal():

Callers

nothing calls this directly

Calls 2

_check_cast_caseFunction · 0.85
DecimalMethod · 0.45

Tested by

no test coverage detected