From c81776e0377af9b0a6a0b0f78146dae37e842585 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Sat, 27 Feb 2016 13:27:54 +0300 Subject: [PATCH] Solve bug with parenthesis and ^ --- pymath/calculus/operator/pw.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pymath/calculus/operator/pw.py b/pymath/calculus/operator/pw.py index 8b8cbaa..5d2d1d3 100644 --- a/pymath/calculus/operator/pw.py +++ b/pymath/calculus/operator/pw.py @@ -19,7 +19,7 @@ class Pw(Operator): >>> pw.__tex__('2','-3') '2^{ -3 }' >>> pw.__tex__('-2','3') - '( -2 )^{ -3 }' + '( -2 )^{ 3 }' >>> pw.__txt__('2','3') '2 ^ 3' >>> pw.__txt__('-2','3') @@ -66,6 +66,19 @@ class Pw(Operator): ans = ' '.join([str(i) for i in ans]) return ans + def __tex__(self, *args): + """Tex rendering for ^ + + :*args: Operands for this operation + :returns: String with operator and his operands + + """ + op1 = self.l_parenthesis(args[0], True) + op2 = args[1] + ans = self.tex.format(op1 = op1, op2 = op2) + + return ans + # ----------------------------- # Reglages pour 'vim'