99import numpy as np
1010import numpy .typing as npt
1111
12- from zarr .core .buffer import core
12+ import zarr .core .buffer
1313from zarr .registry import (
1414 register_buffer ,
1515 register_ndbuffer ,
1919 from collections .abc import Callable , Iterable
2020 from typing import Self
2121
22- from zarr .core .buffer . core import ArrayLike , NDArrayLike
22+ from zarr .core .buffer import ArrayLike , NDArrayLike
2323 from zarr .core .common import BytesLike
2424
2525
26- class Buffer (core .Buffer ):
26+ class Buffer (zarr . core . buffer .Buffer ):
2727 """A flat contiguous memory block
2828
2929 We use Buffer throughout Zarr to represent a contiguous block of memory.
@@ -52,7 +52,7 @@ def create_zero_length(cls) -> Self:
5252 return cls (np .array ([], dtype = "b" ))
5353
5454 @classmethod
55- def from_buffer (cls , buffer : core .Buffer ) -> Self :
55+ def from_buffer (cls , buffer : zarr . core . buffer .Buffer ) -> Self :
5656 """Create a new buffer of an existing Buffer
5757
5858 This is useful if you want to ensure that an existing buffer is
@@ -107,7 +107,7 @@ def as_numpy_array(self) -> npt.NDArray[Any]:
107107 """
108108 return np .asanyarray (self ._data )
109109
110- def __add__ (self , other : core .Buffer ) -> Self :
110+ def __add__ (self , other : zarr . core . buffer .Buffer ) -> Self :
111111 """Concatenate two buffers"""
112112
113113 other_array = other .as_array_like ()
@@ -117,7 +117,7 @@ def __add__(self, other: core.Buffer) -> Self:
117117 )
118118
119119
120- class NDBuffer (core .NDBuffer ):
120+ class NDBuffer (zarr . core . buffer .NDBuffer ):
121121 """An n-dimensional memory block
122122
123123 We use NDBuffer throughout Zarr to represent a n-dimensional memory block.
@@ -186,8 +186,10 @@ def __setitem__(self, key: Any, value: Any) -> None:
186186
187187
188188def as_numpy_array_wrapper (
189- func : Callable [[npt .NDArray [Any ]], bytes ], buf : core .Buffer , prototype : core .BufferPrototype
190- ) -> core .Buffer :
189+ func : Callable [[npt .NDArray [Any ]], bytes ],
190+ buf : zarr .core .buffer .Buffer ,
191+ prototype : zarr .core .buffer .BufferPrototype ,
192+ ) -> zarr .core .buffer .Buffer :
191193 """Converts the input of `func` to a numpy array and the output back to `Buffer`.
192194
193195 This function is useful when calling a `func` that only support host memory such
@@ -214,13 +216,13 @@ def as_numpy_array_wrapper(
214216
215217
216218# CPU buffer prototype using numpy arrays
217- buffer_prototype = core .BufferPrototype (buffer = Buffer , nd_buffer = NDBuffer )
219+ buffer_prototype = zarr . core . buffer .BufferPrototype (buffer = Buffer , nd_buffer = NDBuffer )
218220# default_buffer_prototype = buffer_prototype
219221
220222
221223# The numpy prototype used for E.g. when reading the shard index
222- def numpy_buffer_prototype () -> core .BufferPrototype :
223- return core .BufferPrototype (buffer = Buffer , nd_buffer = NDBuffer )
224+ def numpy_buffer_prototype () -> zarr . core . buffer .BufferPrototype :
225+ return zarr . core . buffer .BufferPrototype (buffer = Buffer , nd_buffer = NDBuffer )
224226
225227
226228register_buffer (Buffer )
0 commit comments