@@ -611,11 +611,19 @@ def __neg__(self):
611611 arr = operator .inv (values )
612612 else :
613613 arr = operator .neg (values )
614- return self ._wrap_array (arr , self . axes , copy = False )
614+ return self .__array_wrap__ (arr )
615615
616616 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
619627
620628 def equals (self , other ):
621629 """
@@ -707,15 +715,11 @@ def __abs__(self):
707715 #----------------------------------------------------------------------
708716 # Array Interface
709717
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-
714718 def __array__ (self , dtype = None ):
715719 return _values_from_object (self )
716720
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 )
719723 return self ._constructor (result , ** d ).__finalize__ (self )
720724
721725 # ideally we would define this to avoid the getattr checks, but
0 commit comments