From a0cf4c1f6743975742a7f3712c4fd230f2d7297e Mon Sep 17 00:00:00 2001 From: lafrite Date: Mon, 22 Jun 2015 09:13:07 +0200 Subject: [PATCH] solve bug#4 can create fraction of fractions --- pymath/fraction.py | 3 +++ pymath/polynom.py | 34 ---------------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/pymath/fraction.py b/pymath/fraction.py index 61c2d49..6b98378 100644 --- a/pymath/fraction.py +++ b/pymath/fraction.py @@ -61,6 +61,9 @@ class Fraction(Explicable): if self._num == 0: return Expression([0]) + elif type(self._num) == Fraction or type(self._denom) == Fraction: + return self._num / self._denom + elif self._denom < 0: n_frac = Fraction(-self._num, -self._denom) ans = n_frac.simplify() diff --git a/pymath/polynom.py b/pymath/polynom.py index 4caa56f..e189cb6 100644 --- a/pymath/polynom.py +++ b/pymath/polynom.py @@ -176,40 +176,6 @@ for name, func in inspect.getmembers(Polynom): setattr(Polynom, name, polynom_factory(func)) -def test(p,q): - print("---------------------") - print("---------------------") - print("p : ",p) - print("q : ",q) - - print("\n Plus ------") - print(p, "+", q) - for i in (p + q): - #print(repr(i)) - #print("\t", str(i.postfix_tokens)) - print(i) - - print("\n Moins ------") - for i in (p - q): - #print(repr(i)) - #print("\t", str(i.postfix_tokens)) - print(i) - - print("\n Multiplier ------") - for i in (p * q): - #print(repr(i)) - #print("\t", str(i.postfix_tokens)) - print(i) - - print("\n Evaluer p ------") - for i in p(3).simplify(): - print(i) - - print("\n Evaluer q ------") - for i in q(3).simplify(): - print(i) - - if __name__ == '__main__': #from .fraction import Fraction #with Expression.tmp_render(txt):