diff --git a/pymath/calculus/operator/operator.py b/pymath/calculus/operator/operator.py index ae0a1ed..6ac72df 100644 --- a/pymath/calculus/operator/operator.py +++ b/pymath/calculus/operator/operator.py @@ -180,11 +180,12 @@ class Operator(): ans = ' '.join([str(i) for i in ans]) return ans - def r_parenthesis(self, op, str_join=False): + def r_parenthesis(self, opr, str_join=False): """ Add parenthesis for rigth operand if necessary """ - ans = op + ans = opr try: - if op.mainOp.priority < self.priority: + if opr.mainOp.priority < self.priority or \ + (opr.mainOp.name == 'mul' and opr[0] == '-'): ans = flatten_list(["(", ans, ")"]) except AttributeError: # op has not the attribute priority