|
5 | 5 | from enum import Enum |
6 | 6 | from typing import TYPE_CHECKING |
7 | 7 |
|
8 | | -import numpy as np |
9 | | - |
10 | 8 | from zarr.abc.codec import ArrayBytesCodec |
11 | | -from zarr.core.buffer import Buffer, NDArrayLike, NDBuffer |
| 9 | +from zarr.core.buffer import Buffer, NDBuffer |
12 | 10 | from zarr.core.common import JSON, parse_enum, parse_named_configuration |
13 | 11 | from zarr.core.dtype.common import HasEndianness |
14 | 12 |
|
@@ -72,20 +70,15 @@ async def _decode_single( |
72 | 70 | chunk_bytes: Buffer, |
73 | 71 | chunk_spec: ArraySpec, |
74 | 72 | ) -> NDBuffer: |
75 | | - assert isinstance(chunk_bytes, Buffer) |
76 | 73 | # TODO: remove endianness enum in favor of literal union |
77 | 74 | endian_str = self.endian.value if self.endian is not None else None |
78 | 75 | if isinstance(chunk_spec.dtype, HasEndianness): |
79 | 76 | dtype = replace(chunk_spec.dtype, endianness=endian_str).to_native_dtype() # type: ignore[call-arg] |
80 | 77 | else: |
81 | 78 | dtype = chunk_spec.dtype.to_native_dtype() |
82 | 79 | as_array_like = chunk_bytes.as_array_like() |
83 | | - if isinstance(as_array_like, NDArrayLike): |
84 | | - as_nd_array_like = as_array_like |
85 | | - else: |
86 | | - as_nd_array_like = np.asanyarray(as_array_like) |
87 | 80 | chunk_array = chunk_spec.prototype.nd_buffer.from_ndarray_like( |
88 | | - as_nd_array_like.view(dtype=dtype) |
| 81 | + as_array_like.view(dtype=dtype) # type: ignore[attr-defined] |
89 | 82 | ) |
90 | 83 |
|
91 | 84 | # ensure correct chunk shape |
|
0 commit comments