From d2f67a09611c66faece8bf3e93d1ddb28cfcac02 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 10 Oct 2018 10:40:40 +0200 Subject: [PATCH] Fix(Render): Ajust "*" visibility with variables --- mapytex/calculus/API/__init__.py | 3 +++ mapytex/calculus/core/renders/tree2tex.py | 4 +++- mapytex/calculus/core/renders/tree2txt.py | 4 +++- mapytex/calculus/core/typing/multiply.py | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mapytex/calculus/API/__init__.py b/mapytex/calculus/API/__init__.py index 8210e50..1215e64 100644 --- a/mapytex/calculus/API/__init__.py +++ b/mapytex/calculus/API/__init__.py @@ -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) diff --git a/mapytex/calculus/core/renders/tree2tex.py b/mapytex/calculus/core/renders/tree2tex.py index 8c9d74c..9699776 100644 --- a/mapytex/calculus/core/renders/tree2tex.py +++ b/mapytex/calculus/core/renders/tree2tex.py @@ -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: diff --git a/mapytex/calculus/core/renders/tree2txt.py b/mapytex/calculus/core/renders/tree2txt.py index 144f666..6350241 100644 --- a/mapytex/calculus/core/renders/tree2txt.py +++ b/mapytex/calculus/core/renders/tree2txt.py @@ -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: diff --git a/mapytex/calculus/core/typing/multiply.py b/mapytex/calculus/core/typing/multiply.py index 64c1b99..56c43a2 100644 --- a/mapytex/calculus/core/typing/multiply.py +++ b/mapytex/calculus/core/typing/multiply.py @@ -36,7 +36,7 @@ def moscalar_mostr(left, right): >>> a = MOFraction(1, 5) >>> multiply(a, b) - + """ return MOMonomial(left, right) @@ -50,7 +50,7 @@ def mostr_moscalar(left, right): >>> b = MOFraction(1, 5) >>> multiply(a, b) - + """ return MOMonomial(right, left)