| 3570 | |
| 3571 | |
| 3572 | def test_view(): |
| 3573 | x = np.arange(56).reshape((7, 8)) |
| 3574 | d = da.from_array(x, chunks=(2, 3)) |
| 3575 | |
| 3576 | assert_eq(x.view(), d.view()) |
| 3577 | assert_eq(x.view("i4"), d.view("i4")) |
| 3578 | assert_eq(x.view("i2"), d.view("i2")) |
| 3579 | assert all(isinstance(s, int) for s in d.shape) |
| 3580 | |
| 3581 | x = np.arange(8, dtype="i1") |
| 3582 | d = da.from_array(x, chunks=(4,)) |
| 3583 | assert_eq(x.view("i4"), d.view("i4")) |
| 3584 | |
| 3585 | with pytest.raises(ValueError): |
| 3586 | x = np.arange(8, dtype="i1") |
| 3587 | d = da.from_array(x, chunks=(3,)) |
| 3588 | d.view("i4") |
| 3589 | |
| 3590 | with pytest.raises(ValueError): |
| 3591 | d.view("i4", order="asdf") |
| 3592 | |
| 3593 | |
| 3594 | def test_view_fortran(): |