File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 cast ,
99)
1010
11- import numpy as np
12- import numpy .typing as npt
13-
1411from zarr .core .buffer import core
1512from zarr .core .buffer .core import ArrayLike , BufferPrototype , NDArrayLike
1613from zarr .registry import (
2219 from collections .abc import Iterable
2320 from typing import Self
2421
22+ import numpy .typing as npt
23+
2524 from zarr .core .common import BytesLike , ChunkCoords
2625
2726try :
@@ -106,13 +105,13 @@ def as_numpy_array(self) -> npt.NDArray[Any]:
106105 return cast ("npt.NDArray[Any]" , cp .asnumpy (self ._data ))
107106
108107 def __add__ (self , other : core .Buffer ) -> Self :
109- other_array = other .as_array_like ()
110- assert other_array . dtype == np . dtype ( "B" )
111- gpu_other = Buffer ( other_array )
112- gpu_other_array = gpu_other . as_array_like ( )
113- return self . __class__ (
114- cp .concatenate (( cp . asanyarray ( self . _data ), cp . asanyarray ( gpu_other_array )) )
115- )
108+ other_array = cp . asanyarray ( other .as_array_like () )
109+ left = self . _data
110+ if left . dtype != other_array . dtype :
111+ other_array = other_array . view ( left . dtype )
112+
113+ buffer = cp .concatenate ([ left , other_array ] )
114+ return type ( self )( buffer )
116115
117116
118117class NDBuffer (core .NDBuffer ):
You can’t perform that action at this time.
0 commit comments