Fix(Render): Ajust "*" visibility with variables

This commit is contained in:
Bertrand Benjamin 2018-10-10 10:40:40 +02:00
parent e6abc208a0
commit d2f67a0961
4 changed files with 11 additions and 4 deletions

View File

@ -20,6 +20,7 @@ Generate and compute like a student!
2 + 3 * 4
2 + 12
14
>>> e = Expression.from_str("2+3/2")
>>> e_simplified = e.simplify()
>>> print(e_simplified)
@ -32,6 +33,7 @@ Generate and compute like a student!
4 / 2 + 3 / 2
(4 + 3) / 2
7 / 2
>>> e = Expression.from_str("(2/3)^4")
>>> e_simplified = e.simplify()
>>> print(e_simplified)
@ -41,6 +43,7 @@ Generate and compute like a student!
(2 / 3)^4
2^4 / 3^4
16 / 81
>>> e = Expression.from_str("x^2*x*x^4")
>>> e_simplified = e.simplify()
>>> print(e_simplified)

View File

@ -94,6 +94,8 @@ def mul2tex(left, right):
>>> a = mo.MOstr('x')
>>> mul2tex(mo.MO(3), a)
'3x'
>>> mul2tex(a, a)
'x \\times x'
"""
display_time = True
try:
@ -121,7 +123,7 @@ def mul2tex(left, right):
else:
right_ = tree2tex(right)
finally:
if right_[0].isalpha():
if right_[0].isalpha() and (left_.isnumeric() or left_.isdecimal()):
display_time = False
if display_time:

View File

@ -94,6 +94,8 @@ def mul2txt(left, right):
>>> a = mo.MOstr('x')
>>> mul2txt(mo.MO(3), a)
'3x'
>>> mul2txt(a, a)
'x * x'
"""
display_time = True
try:
@ -121,7 +123,7 @@ def mul2txt(left, right):
else:
right_ = tree2txt(right)
finally:
if right_[0].isalpha():
if right_[0].isalpha() and (left_.isnumeric() or left_.isdecimal()):
display_time = False
if display_time:

View File

@ -36,7 +36,7 @@ def moscalar_mostr(left, right):
<MOMonomial 2x>
>>> a = MOFraction(1, 5)
>>> multiply(a, b)
<MOMonomial 1 / 5x>
<MOMonomial 1 / 5 * x>
"""
return MOMonomial(left, right)
@ -50,7 +50,7 @@ def mostr_moscalar(left, right):
<MOMonomial 2x>
>>> b = MOFraction(1, 5)
>>> multiply(a, b)
<MOMonomial 1 / 5x>
<MOMonomial 1 / 5 * x>
"""
return MOMonomial(right, left)