@@ -1502,13 +1502,16 @@ def value_counts(self):
15021502 # """
15031503 # return np.ndarray.__array_prepare__(self.data, arr, context)
15041504
1505- def __array_wrap__ (self , out_arr , context = None ) -> 'Array' :
1505+ def __array_wrap__ (self , out_arr , context = None , return_scalar = False ) -> 'Array' :
15061506 r"""
15071507 Called after numpy ufuncs. This is never called during our wrapped
15081508 ufuncs, but if somebody uses raw numpy function, this works in some
15091509 cases.
15101510 """
1511- data = np .ndarray .__array_wrap__ (self .data , out_arr , context )
1511+ # as far as I understand this, this line will only ever be useful if
1512+ # our .data attribute is not a np.ndarray but an array-ish. It gives
1513+ # that other type (cupy array or whatever) the oportunity
1514+ data = self .data .__array_wrap__ (out_arr , context )
15121515 return Array (data , self .axes )
15131516
15141517 def __bool__ (self ):
@@ -7345,8 +7348,13 @@ def item(self) -> Scalar:
73457348 def __len__ (self ) -> int :
73467349 return len (self .data )
73477350
7348- def __array__ (self , dtype = None ):
7349- return np .asarray (self .data , dtype = dtype )
7351+ # numpy < 2 does not use the copy argument
7352+ def __array__ (self , dtype = None , copy = None ):
7353+ if copy is None :
7354+ # numpy < 2 does not support np.array(copy=None)
7355+ return np .asarray (self .data , dtype = dtype )
7356+ else :
7357+ return np .array (self .data , dtype = dtype , copy = copy )
73507358
73517359 __array_priority__ = 100
73527360
0 commit comments