@@ -611,11 +611,19 @@ def __neg__(self):
611
611
arr = operator .inv (values )
612
612
else :
613
613
arr = operator .neg (values )
614
- return self ._wrap_array (arr , self . axes , copy = False )
614
+ return self .__array_wrap__ (arr )
615
615
616
616
def __invert__ (self ):
617
- arr = operator .inv (_values_from_object (self ))
618
- return self ._wrap_array (arr , self .axes , copy = False )
617
+ try :
618
+ arr = operator .inv (_values_from_object (self ))
619
+ return self .__array_wrap__ (arr )
620
+ except :
621
+
622
+ # inv fails with 0 len
623
+ if not np .prod (self .shape ):
624
+ return self
625
+
626
+ raise
619
627
620
628
def equals (self , other ):
621
629
"""
@@ -707,15 +715,11 @@ def __abs__(self):
707
715
#----------------------------------------------------------------------
708
716
# Array Interface
709
717
710
- def _wrap_array (self , arr , axes , copy = False ):
711
- d = self ._construct_axes_dict_from (self , axes , copy = copy )
712
- return self ._constructor (arr , ** d ).__finalize__ (self )
713
-
714
718
def __array__ (self , dtype = None ):
715
719
return _values_from_object (self )
716
720
717
- def __array_wrap__ (self , result ):
718
- d = self ._construct_axes_dict (self ._AXIS_ORDERS , copy = False )
721
+ def __array_wrap__ (self , result , copy = False ):
722
+ d = self ._construct_axes_dict (self ._AXIS_ORDERS , copy = copy )
719
723
return self ._constructor (result , ** d ).__finalize__ (self )
720
724
721
725
# ideally we would define this to avoid the getattr checks, but
0 commit comments