Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed May 14, 2024
1 parent 36c6253 commit 3319359
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2283,8 +2283,11 @@ def _process_for_setitem(self, ckey, chunk_selection, value, fields=None):
chunk.fill(value)

else:
# ensure array is contiguous
chunk = value.astype(self._dtype, order=self._order, copy=False)
if not isinstance(value, np.ndarray):
chunk = np.asarray(value, dtype=self._dtype, order=self._order)
else:
# ensure array is contiguous
chunk = value.astype(self._dtype, order=self._order, copy=False)

else:
# partially replace the contents of this chunk
Expand Down
3 changes: 3 additions & 0 deletions zarr/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3167,3 +3167,6 @@ def test_scalar_indexing():

assert store["a"][1] == np.array(2.0)
assert store["a"][(1,)] == np.array(2.0)

store["a"][0] = [-1]
assert store["a"][0] == np.array(-1)

0 comments on commit 3319359

Please sign in to comment.