File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -1399,11 +1399,21 @@ def opmethod(self, other):
1399
1399
__or__ = _binop ('or' )
1400
1400
__ror__ = _binop ('ror' )
1401
1401
1402
+ # element-wise method factory
1403
+ def _unaryop (opname ):
1404
+ fullname = '__%s__' % opname
1405
+ super_method = getattr (np .ndarray , fullname )
1406
+
1407
+ def opmethod (self ):
1408
+ return LArray (super_method (self .data ), self .axes )
1409
+ opmethod .__name__ = fullname
1410
+ return opmethod
1411
+
1402
1412
# unary ops do not need broadcasting so do not need to be overridden
1403
- # __neg__ = _unaryop('neg')
1404
- # __pos__ = _unaryop('pos')
1405
- # __abs__ = _unaryop('abs')
1406
- # __invert__ = _unaryop('invert')
1413
+ __neg__ = _unaryop ('neg' )
1414
+ __pos__ = _unaryop ('pos' )
1415
+ __abs__ = _unaryop ('abs' )
1416
+ __invert__ = _unaryop ('invert' )
1407
1417
1408
1418
def append (self , ** kwargs ):
1409
1419
label = kwargs .pop ('label' , None )
You can’t perform that action at this time.
0 commit comments