Skip to content

Commit d747f4c

Browse files
jakirkhamalimanfoo
authored andcommitted
Use ensure_ndarray to view chunk as an array (#360)
* Use `ensure_ndarray` to view chunk as an array Simplifies the process of constructing an `ndarray` to view the chunk data when writing the result to a destination. * Drop trailing whitespace * Link this PR to Numcodecs upgrade release note
1 parent 8e18c81 commit d747f4c

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

docs/release.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Bug fixes
2929

3030
* The required version of the `numcodecs <http://numcodecs.rtfd.io>`_ package has been upgraded
3131
to 0.6.2, which has enabled some code simplification and fixes a failing test involving
32-
msgpack encoding. By :user:`John Kirkham <jakirkham>`, :issue:`352`, :issue:`355`,
32+
msgpack encoding. By :user:`John Kirkham <jakirkham>`, :issue:`360`, :issue:`352`, :issue:`355`,
3333
:issue:`324`.
3434

3535
* Failing tests related to pickling/unpickling have been fixed. By :user:`Ryan Williams <ryan-williams>`,

zarr/core.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,10 +1604,7 @@ def _chunk_getitem(self, chunk_coords, chunk_selection, out, out_selection,
16041604
if self._compressor:
16051605
self._compressor.decode(cdata, dest)
16061606
else:
1607-
if isinstance(cdata, np.ndarray):
1608-
chunk = cdata.view(self._dtype)
1609-
else:
1610-
chunk = np.frombuffer(cdata, dtype=self._dtype)
1607+
chunk = ensure_ndarray(cdata).view(self._dtype)
16111608
chunk = chunk.reshape(self._chunks, order=self._order)
16121609
np.copyto(dest, chunk)
16131610
return

0 commit comments

Comments
 (0)