Ver código fonte

Added __pos__ operator for negation reduction.

Taddeus Kroes 14 anos atrás
pai
commit
0b791b7f63
1 arquivos alterados com 5 adições e 0 exclusões
  1. 5 0
      src/node.py

+ 5 - 0
src/node.py

@@ -145,8 +145,13 @@ class ExpressionBase(object):
     def __pow__(self, other):
         return ExpressionNode('^', self, to_expression(other))
 
+    def __pos__(self):
+        return self.reduce_negation()
+
     def reduce_negation(self, n=1):
         """Remove n negation flags from the node."""
+        assert self.negated
+
         return self.negate(-n)
 
     def negate(self, n=1):