| 2070 | |
| 2071 | |
| 2072 | def test_cast_string_to_number_roundtrip(): |
| 2073 | cases = [ |
| 2074 | (pa.array(["1", "127", "-128"]), |
| 2075 | pa.array([1, 127, -128], type=pa.int8())), |
| 2076 | (pa.array([None, "18446744073709551615"]), |
| 2077 | pa.array([None, 18446744073709551615], type=pa.uint64())), |
| 2078 | ] |
| 2079 | for in_arr, expected in cases: |
| 2080 | casted = in_arr.cast(expected.type, safe=True) |
| 2081 | casted.validate(full=True) |
| 2082 | assert casted.equals(expected) |
| 2083 | casted_back = casted.cast(in_arr.type, safe=True) |
| 2084 | casted_back.validate(full=True) |
| 2085 | assert casted_back.equals(in_arr) |
| 2086 | |
| 2087 | |
| 2088 | def test_cast_dictionary(): |