| 4170 | |
| 4171 | |
| 4172 | def test_array_accepts_pyarrow_array(): |
| 4173 | arr = pa.array([1, 2, 3]) |
| 4174 | result = pa.array(arr) |
| 4175 | assert arr == result |
| 4176 | |
| 4177 | # Test casting to a different type |
| 4178 | result = pa.array(arr, type=pa.uint8()) |
| 4179 | expected = pa.array([1, 2, 3], type=pa.uint8()) |
| 4180 | assert expected == result |
| 4181 | assert expected.type == pa.uint8() |
| 4182 | |
| 4183 | # Test casting with safe keyword |
| 4184 | arr = pa.array([2 ** 63 - 1], type=pa.int64()) |
| 4185 | |
| 4186 | with pytest.raises(pa.ArrowInvalid): |
| 4187 | pa.array(arr, type=pa.int32()) |
| 4188 | |
| 4189 | expected = pa.array([-1], type=pa.int32()) |
| 4190 | result = pa.array(arr, type=pa.int32(), safe=False) |
| 4191 | assert result == expected |
| 4192 | |
| 4193 | # Test memory_pool keyword is accepted |
| 4194 | result = pa.array(arr, memory_pool=pa.default_memory_pool()) |
| 4195 | assert arr == result |
| 4196 | |
| 4197 | |
| 4198 | def check_run_end_encoded(ree_array, run_ends, values, logical_length, physical_length, |