|
22 | 22 |
|
23 | 23 | from zarr.codecs.bytes import Endian |
24 | 24 | from zarr.core.common import BytesLike, ChunkCoords |
| 25 | + from zarr.core.indexing import Selection |
25 | 26 |
|
26 | 27 | # Everything here is imported into ``zarr.core.buffer`` namespace. |
27 | 28 | __all__: list[str] = [] |
@@ -129,12 +130,12 @@ def shape(self) -> tuple[()]: |
129 | 130 | def __len__(self) -> int: |
130 | 131 | raise TypeError("len() of unsized object.") |
131 | 132 |
|
132 | | - def __getitem__(self, key: slice) -> Self: |
| 133 | + def __getitem__(self, key: Selection) -> Self: |
133 | 134 | if key != slice(None) and key != Ellipsis and key != (): |
134 | 135 | raise IndexError("Invalid index for scalar.") |
135 | 136 | return self |
136 | 137 |
|
137 | | - def __setitem__(self, key: slice, value: Any) -> None: |
| 138 | + def __setitem__(self, key: Selection, value: Any) -> None: |
138 | 139 | if key != slice(None) and key != Ellipsis and key != (): |
139 | 140 | raise IndexError("Invalid index for scalar.") |
140 | 141 | self._value = value |
@@ -560,7 +561,7 @@ def as_scalar(self) -> ScalarWrapper: |
560 | 561 | """ |
561 | 562 | if self._data.size != 1: |
562 | 563 | raise ValueError("Buffer does not contain a single scalar value") |
563 | | - return ScalarWrapper(self.as_numpy_array().item(), self.dtype) |
| 564 | + return ScalarWrapper(self.as_numpy_array().item(), np.dtype(self.dtype)) |
564 | 565 |
|
565 | 566 | @property |
566 | 567 | def dtype(self) -> np.dtype[Any]: |
|
0 commit comments