()
| 1728 | |
| 1729 | @pytest.mark.numpy |
| 1730 | def test_cast_integers_safe(): |
| 1731 | safe_cases = [ |
| 1732 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1733 | np.array([0, 1, 2, 3], dtype='i4'), pa.int32()), |
| 1734 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1735 | np.array([0, 1, 2, 3], dtype='u4'), pa.uint16()), |
| 1736 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1737 | np.array([0, 1, 2, 3], dtype='u1'), pa.uint8()), |
| 1738 | (np.array([0, 1, 2, 3], dtype='i1'), 'int8', |
| 1739 | np.array([0, 1, 2, 3], dtype='f8'), pa.float64()) |
| 1740 | ] |
| 1741 | |
| 1742 | for case in safe_cases: |
| 1743 | _check_cast_case(case) |
| 1744 | |
| 1745 | unsafe_cases = [ |
| 1746 | (np.array([50000], dtype='i4'), 'int32', 'int16'), |
| 1747 | (np.array([70000], dtype='i4'), 'int32', 'uint16'), |
| 1748 | (np.array([-1], dtype='i4'), 'int32', 'uint16'), |
| 1749 | (np.array([50000], dtype='u2'), 'uint16', 'int16') |
| 1750 | ] |
| 1751 | for in_data, in_type, out_type in unsafe_cases: |
| 1752 | in_arr = pa.array(in_data, type=in_type) |
| 1753 | |
| 1754 | with pytest.raises(pa.ArrowInvalid): |
| 1755 | in_arr.cast(out_type) |
| 1756 | |
| 1757 | |
| 1758 | def test_cast_none(): |
nothing calls this directly
no test coverage detected