Skip to content

Commit a6ba456

Browse files
committed
API: add/clarify numpy ufunc prepare/wrap
1 parent 80a3ee4 commit a6ba456

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

pandas/core/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,8 @@ def __abs__(self):
717717
def __array__(self, dtype=None):
718718
return _values_from_object(self)
719719

720-
def __array_wrap__(self, result, copy=False):
721-
d = self._construct_axes_dict(self._AXIS_ORDERS, copy=copy)
720+
def __array_wrap__(self, result, context=None):
721+
d = self._construct_axes_dict(self._AXIS_ORDERS, copy=False)
722722
return self._constructor(result, **d).__finalize__(self)
723723

724724
# ideally we would define this to avoid the getattr checks, but

pandas/core/series.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -366,18 +366,23 @@ def view(self, dtype=None):
366366
index=self.index).__finalize__(self)
367367

368368
def __array__(self, result=None):
369-
""" the array interface, return my values """
369+
"""
370+
the array interface, return my values
371+
"""
370372
return self.values
371373

372-
def __array_wrap__(self, result, copy=False):
374+
def __array_wrap__(self, result, context=None):
373375
"""
374-
Gets called prior to a ufunc (and after)
376+
Gets called after a ufunc
375377
"""
376378
return self._constructor(result, index=self.index,
377-
copy=copy).__finalize__(self)
379+
copy=False).__finalize__(self)
378380

379-
def __contains__(self, key):
380-
return key in self.index
381+
def __array_prepare__(self, result, context=None):
382+
"""
383+
Gets called prior to a ufunc
384+
"""
385+
return result
381386

382387
# complex
383388
@property

0 commit comments

Comments
 (0)