Skip to content

Commit 1797c6f

Browse files
committed
much simpler test
1 parent 83faf56 commit 1797c6f

File tree

3 files changed

+10
-27
lines changed

3 files changed

+10
-27
lines changed

src/zarr/core/codec_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def _merge_chunk_array(
309309
for idx in range(chunk_spec.ndim)
310310
)
311311
chunk_value = chunk_value[item]
312-
if is_complete_chunk:
312+
if is_complete_chunk and chunk_value.shape == chunk_spec.shape:
313313
# TODO: For the last chunk, we could have is_complete_chunk=True
314314
# that is smaller than the chunk_spec.shape but this throws
315315
# an error in the _decode_single

tests/test_array.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -829,32 +829,6 @@ def test_append_bad_shape(store: MemoryStore, zarr_format: ZarrFormat) -> None:
829829
z.append(b)
830830

831831

832-
def test_append_shape_not_equals_chunk_shape() -> None:
833-
# regression test for GH2849
834-
g = zarr.open("foo.zarr", zarr_format=3, mode="w")
835-
g["bar"] = np.arange(3)
836-
837-
size = 4
838-
data = [0, 1, 2, 3]
839-
g["bar"].append(data)
840-
assert (g["bar"][-size:] == data).all(), (g["bar"][-size:], data)
841-
842-
size = 3
843-
data = [-1, -2, -3]
844-
g["bar"].append(data)
845-
assert (g["bar"][-size:] == data).all(), (g["bar"][-size:], data)
846-
847-
size = 2
848-
data = [-10, -11]
849-
g["bar"].append(data)
850-
assert (g["bar"][-size:] == data).all(), (g["bar"][-size:], data)
851-
852-
size = 3
853-
data = [-4, -5, -6]
854-
g["bar"].append(data)
855-
assert (g["bar"][-size:] == data).all(), (g["bar"][-size:], data)
856-
857-
858832
@pytest.mark.parametrize("store", ["memory"], indirect=True)
859833
@pytest.mark.parametrize("write_empty_chunks", [True, False])
860834
@pytest.mark.parametrize("fill_value", [0, 5])

tests/test_indexing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,15 @@ def test_set_orthogonal_selection_1d(store: StorePath) -> None:
815815
_test_set_orthogonal_selection(v, a, z, selection)
816816

817817

818+
def test_set_orthogonal_selection_1d_last_two_chunks():
819+
# regression test for GH2849
820+
g = zarr.open_group("foo.zarr", zarr_format=3, mode="w")
821+
a = g.create_array("bar", shape=(10,), chunks=(3,), dtype=int)
822+
data = np.array([7, 8, 9])
823+
a[slice(7, 10)] = data
824+
np.testing.assert_array_equal(a[slice(7, 10)], data)
825+
826+
818827
def _test_set_orthogonal_selection_2d(
819828
v: npt.NDArray[np.int_],
820829
a: npt.NDArray[np.int_],

0 commit comments

Comments
 (0)