From b508a8afb4a05d6feb93858921f455c2b5fc8ab8 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Tue, 10 Mar 2015 14:04:04 +0100 Subject: [PATCH] all tested are passed! :D --- pymath/operator.py | 10 +++++++++- test/test_operator.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pymath/operator.py b/pymath/operator.py index 8ef319e..35e2a19 100644 --- a/pymath/operator.py +++ b/pymath/operator.py @@ -434,7 +434,12 @@ class op(object): return True elif op2.isalpha(): return False - elif (op2[0] == "(" or op2[0].isdecimal()) and not ("+" in op2): + elif op2[0].isdecimal(): + return True + elif op2[0] == "(" and not ("+" in op2 or "-" in op2[3:]): + return True + # Giga bricolage... + elif "frac" in op2: return True else: return False @@ -586,6 +591,9 @@ if __name__ == '__main__': from .polynom import Polynom print(tex([Polynom([1,2,3]), 2, op.mul])) print("-----------------") + from .fraction import Fraction + print(tex([2, Fraction(1,2), op.mul])) + print("-----------------") #import doctest #doctest.testmod() diff --git a/test/test_operator.py b/test/test_operator.py index 6820e45..c89f9fd 100644 --- a/test/test_operator.py +++ b/test/test_operator.py @@ -9,7 +9,7 @@ def test_mul_is_visible(): assert op.mul.is_visible(2,-3) == True assert op.mul.is_visible(-2,3) == True assert op.mul.is_visible('a',2) == True - assert op.mul.is_visible('2a + 1', 2) == True + assert op.mul.is_visible('(2a + 1)', 2) == True assert op.mul.is_visible(2, '(-2)') == True assert op.mul.is_visible(2, '2a') == True assert op.mul.is_visible(2, '(-2a)') == True