()
| 1613 | |
| 1614 | @pytest.mark.numpy |
| 1615 | def test_cast_integers_safe(): |
| 1616 | safe_cases = [ |
| 1617 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1618 | np.array([0, 1, 2, 3], dtype='i4'), pa.int32()), |
| 1619 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1620 | np.array([0, 1, 2, 3], dtype='u4'), pa.uint16()), |
| 1621 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1622 | np.array([0, 1, 2, 3], dtype='u1'), pa.uint8()), |
| 1623 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1624 | np.array([0, 1, 2, 3], dtype='f8'), pa.float64()) |
| 1625 | ] |
| 1626 | |
| 1627 | for case in safe_cases: |
| 1628 | _check_cast_case(case) |
| 1629 | |
| 1630 | unsafe_cases = [ |
| 1631 | (np.array([50000], dtype='i4'), 'int32', 'int16'), |
| 1632 | (np.array([70000], dtype='i4'), 'int32', 'uint16'), |
| 1633 | (np.array([-1], dtype='i4'), 'int32', 'uint16'), |
| 1634 | (np.array([50000], dtype='u2'), 'uint16', 'int16') |
| 1635 | ] |
| 1636 | for in_data, in_type, out_type in unsafe_cases: |
| 1637 | in_arr = pa.array(in_data, type=in_type) |
| 1638 | |
| 1639 | with pytest.raises(pa.ArrowInvalid): |
| 1640 | in_arr.cast(out_type) |
| 1641 | |
| 1642 | |
| 1643 | def test_cast_none(): |
nothing calls this directly
no test coverage detected