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

Source from the content-addressed store, hash-verified

1850
1851@pytest.mark.numpy
1852def test_floating_point_truncate_unsafe():
1853 unsafe_cases = [
1854 (np.array([1.1, 2.2, 3.3], dtype='float32'), 'float32',
1855 np.array([1, 2, 3], dtype='i4'), pa.int32()),
1856 (np.array([1.1, 2.2, 3.3], dtype='float64'), 'float64',
1857 np.array([1, 2, 3], dtype='i4'), pa.int32()),
1858 (np.array([-10.1, 20.2, -30.3], dtype='float64'), 'float64',
1859 np.array([-10, 20, -30], dtype='i4'), pa.int32()),
1860 ]
1861 for case in unsafe_cases:
1862 # test safe casting raises
1863 with pytest.raises(pa.ArrowInvalid, match='truncated'):
1864 _check_cast_case(case, safe=True)
1865
1866 # test unsafe casting truncates
1867 _check_cast_case(case, safe=False)
1868
1869
1870def 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