| 2513 | |
| 2514 | @pytest.mark.numpy |
| 2515 | def test_to_numpy_roundtrip(): |
| 2516 | for narr in [ |
| 2517 | np.arange(10, dtype=np.int64), |
| 2518 | np.arange(10, dtype=np.int32), |
| 2519 | np.arange(10, dtype=np.int16), |
| 2520 | np.arange(10, dtype=np.int8), |
| 2521 | np.arange(10, dtype=np.uint64), |
| 2522 | np.arange(10, dtype=np.uint32), |
| 2523 | np.arange(10, dtype=np.uint16), |
| 2524 | np.arange(10, dtype=np.uint8), |
| 2525 | np.arange(10, dtype=np.float64), |
| 2526 | np.arange(10, dtype=np.float32), |
| 2527 | np.arange(10, dtype=np.float16), |
| 2528 | ]: |
| 2529 | arr = pa.array(narr) |
| 2530 | assert narr.dtype == arr.to_numpy().dtype |
| 2531 | np.testing.assert_array_equal(narr, arr.to_numpy()) |
| 2532 | np.testing.assert_array_equal(narr[:6], arr[:6].to_numpy()) |
| 2533 | np.testing.assert_array_equal(narr[2:], arr[2:].to_numpy()) |
| 2534 | np.testing.assert_array_equal(narr[2:6], arr[2:6].to_numpy()) |
| 2535 | |
| 2536 | |
| 2537 | @pytest.mark.numpy |