Skip to content

Commit 3319359

Browse files
committed
1 parent 36c6253 commit 3319359

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

zarr/core.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2283,8 +2283,11 @@ def _process_for_setitem(self, ckey, chunk_selection, value, fields=None):
22832283
chunk.fill(value)
22842284

22852285
else:
2286-
# ensure array is contiguous
2287-
chunk = value.astype(self._dtype, order=self._order, copy=False)
2286+
if not isinstance(value, np.ndarray):
2287+
chunk = np.asarray(value, dtype=self._dtype, order=self._order)
2288+
else:
2289+
# ensure array is contiguous
2290+
chunk = value.astype(self._dtype, order=self._order, copy=False)
22882291

22892292
else:
22902293
# partially replace the contents of this chunk

zarr/tests/test_core.py

+3
Original file line numberDiff line numberDiff line change
@@ -3167,3 +3167,6 @@ def test_scalar_indexing():
31673167

31683168
assert store["a"][1] == np.array(2.0)
31693169
assert store["a"][(1,)] == np.array(2.0)
3170+
3171+
store["a"][0] = [-1]
3172+
assert store["a"][0] == np.array(-1)

0 commit comments

Comments
 (0)