3838    NDBuffer ,
3939    default_buffer_prototype ,
4040)
41+ from  zarr .core .buffer .core  import  NDArrayLike 
4142from  zarr .core .chunk_grids  import  RegularChunkGrid , _auto_partition , normalize_chunks 
4243from  zarr .core .chunk_key_encodings  import  (
4344    ChunkKeyEncoding ,
@@ -1400,7 +1401,7 @@ async def _set_selection(
14001401                    value  =  value .astype (dtype = self .metadata .dtype , order = "A" )
14011402                else :
14021403                    value  =  np .array (value , dtype = self .metadata .dtype , order = "A" )
1403-         value  =  cast (NDArrayOrScalarLike , value )
1404+         value  =  cast (NDArrayLike , value )
14041405        # We accept any ndarray like object from the user and convert it 
14051406        # to a NDBuffer (or subclass). From this point onwards, we only pass 
14061407        # Buffer and NDBuffer between components. 
@@ -2260,7 +2261,7 @@ def _iter_chunk_regions(
22602261
22612262    def  __array__ (
22622263        self , dtype : npt .DTypeLike  |  None  =  None , copy : bool  |  None  =  None 
2263-     ) ->  NDArrayOrScalarLike :
2264+     ) ->  NDArrayLike :
22642265        """ 
22652266        This method is used by numpy when converting zarr.Array into a numpy array. 
22662267        For more information, see https://numpy.org/devdocs/user/basics.interoperability.html#the-array-method 
@@ -2269,9 +2270,13 @@ def __array__(
22692270            msg  =  "`copy=False` is not supported. This method always creates a copy." 
22702271            raise  ValueError (msg )
22712272
2272-         arr_np  =  self [...]
2273-         if  self .ndim  ==  0 :
2274-             arr_np  =  np .array (arr_np )
2273+         arr  =  self [...]
2274+         arr_np : NDArrayLike 
2275+ 
2276+         if  not  hasattr (arr , "astype" ):
2277+             arr_np  =  np .array (arr , dtype = dtype )
2278+         else :
2279+             arr_np  =  arr 
22752280
22762281        if  dtype  is  not   None :
22772282            arr_np  =  arr_np .astype (dtype )
0 commit comments