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