@@ -1502,13 +1502,16 @@ def value_counts(self):
1502
1502
# """
1503
1503
# return np.ndarray.__array_prepare__(self.data, arr, context)
1504
1504
1505
- def __array_wrap__ (self , out_arr , context = None ) -> 'Array' :
1505
+ def __array_wrap__ (self , out_arr , context = None , return_scalar = False ) -> 'Array' :
1506
1506
r"""
1507
1507
Called after numpy ufuncs. This is never called during our wrapped
1508
1508
ufuncs, but if somebody uses raw numpy function, this works in some
1509
1509
cases.
1510
1510
"""
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 )
1512
1515
return Array (data , self .axes )
1513
1516
1514
1517
def __bool__ (self ):
@@ -7345,8 +7348,13 @@ def item(self) -> Scalar:
7345
7348
def __len__ (self ) -> int :
7346
7349
return len (self .data )
7347
7350
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 )
7350
7358
7351
7359
__array_priority__ = 100
7352
7360
0 commit comments