| 
38 | 38 |     create_array,  | 
39 | 39 | )  | 
40 | 40 | from zarr.core.buffer import default_buffer_prototype  | 
 | 41 | +from zarr.core.buffer.core import NDArrayLike  | 
41 | 42 | from zarr.core.buffer.cpu import NDBuffer  | 
42 | 43 | from zarr.core.chunk_grids import _auto_partition  | 
43 | 44 | from zarr.core.common import JSON, MemoryOrder, ZarrFormat  | 
@@ -654,35 +655,43 @@ def test_resize_1d(store: MemoryStore, zarr_format: ZarrFormat) -> None:  | 
654 | 655 |     )  | 
655 | 656 |     a = np.arange(105, dtype="i4")  | 
656 | 657 |     z[:] = a  | 
 | 658 | +    result = z[:]  | 
 | 659 | +    assert isinstance(result, NDArrayLike)  | 
657 | 660 |     assert (105,) == z.shape  | 
658 |  | -    assert hasattr(z[:], "shape") and (105,) == z[:].shape  | 
 | 661 | +    assert (105,) == result.shape  | 
659 | 662 |     assert np.dtype("i4") == z.dtype  | 
660 |  | -    assert hasattr(z[:], "dtype") and np.dtype("i4") == z[:].dtype  | 
 | 663 | +    assert np.dtype("i4") == result.dtype  | 
661 | 664 |     assert (10,) == z.chunks  | 
662 |  | -    np.testing.assert_array_equal(a, z[:])  | 
 | 665 | +    np.testing.assert_array_equal(a, result)  | 
663 | 666 | 
 
  | 
664 | 667 |     z.resize(205)  | 
 | 668 | +    result = z[:]  | 
 | 669 | +    assert isinstance(result, NDArrayLike)  | 
665 | 670 |     assert (205,) == z.shape  | 
666 |  | -    assert (205,) == z[:].shape  | 
 | 671 | +    assert (205,) == result.shape  | 
667 | 672 |     assert np.dtype("i4") == z.dtype  | 
668 |  | -    assert np.dtype("i4") == z[:].dtype  | 
 | 673 | +    assert np.dtype("i4") == result.dtype  | 
669 | 674 |     assert (10,) == z.chunks  | 
670 | 675 |     np.testing.assert_array_equal(a, z[:105])  | 
671 | 676 |     np.testing.assert_array_equal(np.zeros(100, dtype="i4"), z[105:])  | 
672 | 677 | 
 
  | 
673 | 678 |     z.resize(55)  | 
 | 679 | +    result = z[:]  | 
 | 680 | +    assert isinstance(result, NDArrayLike)  | 
674 | 681 |     assert (55,) == z.shape  | 
675 |  | -    assert (55,) == z[:].shape  | 
 | 682 | +    assert (55,) == result.shape  | 
676 | 683 |     assert np.dtype("i4") == z.dtype  | 
677 |  | -    assert np.dtype("i4") == z[:].dtype  | 
 | 684 | +    assert np.dtype("i4") == result.dtype  | 
678 | 685 |     assert (10,) == z.chunks  | 
679 |  | -    np.testing.assert_array_equal(a[:55], z[:])  | 
 | 686 | +    np.testing.assert_array_equal(a[:55], result)  | 
680 | 687 | 
 
  | 
681 | 688 |     # via shape setter  | 
682 | 689 |     new_shape = (105,)  | 
683 | 690 |     z.shape = new_shape  | 
 | 691 | +    result = z[:]  | 
 | 692 | +    assert isinstance(result, NDArrayLike)  | 
684 | 693 |     assert new_shape == z.shape  | 
685 |  | -    assert new_shape == z[:].shape  | 
 | 694 | +    assert new_shape == result.shape  | 
686 | 695 | 
 
  | 
687 | 696 | 
 
  | 
688 | 697 | @pytest.mark.parametrize("store", ["memory"], indirect=True)  | 
 | 
0 commit comments