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:1948–1980  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1946
1947
1948def test_decimal_to_int_non_integer():
1949 non_integer_cases = [
1950 (
1951 [
1952 decimal.Decimal("123456.21"),
1953 None,
1954 decimal.Decimal("-912345.13")
1955 ],
1956 pa.decimal128(32, 5),
1957 [123456, None, -912345],
1958 pa.int32()
1959 ),
1960 (
1961 [decimal.Decimal("1234.134"), None, decimal.Decimal("-9123.1")],
1962 pa.decimal128(19, 10),
1963 [1234, None, -9123],
1964 pa.int16()
1965 ),
1966 (
1967 [decimal.Decimal("123.1451"), None, decimal.Decimal("-91.21")],
1968 pa.decimal128(19, 10),
1969 [123, None, -91],
1970 pa.int8()
1971 ),
1972 ]
1973
1974 for case in non_integer_cases:
1975 # test safe casting raises
1976 msg_regexp = 'Rescaling Decimal value would cause data loss'
1977 with pytest.raises(pa.ArrowInvalid, match=msg_regexp):
1978 _check_cast_case(case)
1979
1980 _check_cast_case(case, safe=False)
1981
1982
1983def 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