From e031f9b903a63fe82e92c9cd76db782b11a20753 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sat, 7 Mar 2015 18:23:10 +0100 Subject: [PATCH] reset priorities --- pymath/operator.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pymath/operator.py b/pymath/operator.py index 2ba1234..701486e 100644 --- a/pymath/operator.py +++ b/pymath/operator.py @@ -139,10 +139,15 @@ class Operator(str): return ans def add_parenthesis(self, op): - """ Add parenthesis if necessary """ + """ Add parenthesis if necessary + + >>> from pymath.polynom import Polynom + >>> P = Polynom([1,2,3]) + + """ try: if op.mainOp.priority < self.priority: - op = flatten_list(["("] + [op] + [")"]) + op = flatten_list(["(", op, ")"]) except AttributeError: # op has not the attribute priority try: @@ -293,7 +298,7 @@ class op(object): caract = { "operator" : "-", \ "name" : "sub",\ - "priority" : 1, \ + "priority" : 2, \ "arity" : 2, \ "actions" : ("__sub__","__rsub__"), \ "txt" : "{op1} - {op2}",\ @@ -336,7 +341,7 @@ class op(object): caract = { "operator" : "-", \ "name" : "sub1",\ - "priority" : 2, \ + "priority" : 3, \ "arity" : 1, \ "actions" : "__neg__",\ "txt" : "- {op1}",\ @@ -461,7 +466,7 @@ class op(object): caract = { "operator" : "^", \ "name" : "pw",\ - "priority" : 5, \ + "priority" : 6, \ "arity" : 2, \ "actions" : ("__pow__",""), \ "txt" : "{op1} ^ {op2}",\