Skip to content

Commit bf4eee8

Browse files
committed
Ensure chunk in _decode_chunk is an ndarray
1 parent aee5ace commit bf4eee8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

zarr/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
import numpy as np
11-
from numcodecs.compat import ensure_contiguous_ndarray
11+
from numcodecs.compat import ensure_ndarray, ensure_contiguous_ndarray
1212

1313

1414
from zarr.util import (is_total_slice, human_readable_size, normalize_resize_args,
@@ -1745,10 +1745,11 @@ def _decode_chunk(self, cdata):
17451745
chunk = f.decode(chunk)
17461746

17471747
# view as numpy array with correct dtype
1748+
chunk = ensure_ndarray(chunk)
17481749
if self._dtype == object:
17491750
# special case object dtype, because incorrect handling can lead to
17501751
# segfaults and other bad things happening
1751-
if isinstance(chunk, np.ndarray) and chunk.dtype == object:
1752+
if chunk.dtype == object:
17521753
# chunk is already of correct dtype, good to carry on
17531754
# flatten just to be sure we can reshape later
17541755
chunk = chunk.reshape(-1, order='A')

0 commit comments

Comments
 (0)