Solve bug with parenthesis and ^

This commit is contained in:
Benjamin Bertrand 2016-02-27 13:27:54 +03:00
parent e0fb4da8ef
commit c81776e037

View File

@ -19,7 +19,7 @@ class Pw(Operator):
>>> pw.__tex__('2','-3') >>> pw.__tex__('2','-3')
'2^{ -3 }' '2^{ -3 }'
>>> pw.__tex__('-2','3') >>> pw.__tex__('-2','3')
'( -2 )^{ -3 }' '( -2 )^{ 3 }'
>>> pw.__txt__('2','3') >>> pw.__txt__('2','3')
'2 ^ 3' '2 ^ 3'
>>> pw.__txt__('-2','3') >>> pw.__txt__('-2','3')
@ -66,6 +66,19 @@ class Pw(Operator):
ans = ' '.join([str(i) for i in ans]) ans = ' '.join([str(i) for i in ans])
return 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' # Reglages pour 'vim'