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

Function test_floating_point_truncate_unsafe

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

Source from the content-addressed store, hash-verified

1735
1736@pytest.mark.numpy
1737def test_floating_point_truncate_unsafe():
1738 unsafe_cases = [
1739 (np.array([1.1, 2.2, 3.3], dtype='float32'), 'float32',
1740 np.array([1, 2, 3], dtype='i4'), pa.int32()),
1741 (np.array([1.1, 2.2, 3.3], dtype='float64'), 'float64',
1742 np.array([1, 2, 3], dtype='i4'), pa.int32()),
1743 (np.array([-10.1, 20.2, -30.3], dtype='float64'), 'float64',
1744 np.array([-10, 20, -30], dtype='i4'), pa.int32()),
1745 ]
1746 for case in unsafe_cases:
1747 # test safe casting raises
1748 with pytest.raises(pa.ArrowInvalid, match='truncated'):
1749 _check_cast_case(case, safe=True)
1750
1751 # test unsafe casting truncates
1752 _check_cast_case(case, safe=False)
1753
1754
1755def test_half_float_array_from_python():

Callers

nothing calls this directly

Calls 2

_check_cast_caseFunction · 0.85
arrayMethod · 0.45

Tested by

no test coverage detected