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