From a3c84d6eabf54185dbc8feb6fce34c72b71aacde Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sun, 2 Nov 2014 11:17:12 +0100 Subject: [PATCH] ok Operator well included need to use them correctly now! --- pymath/operator.py | 4 +++- test/test_expression.py | 12 ------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/pymath/operator.py b/pymath/operator.py index 138ea65..3deba4a 100644 --- a/pymath/operator.py +++ b/pymath/operator.py @@ -2,6 +2,8 @@ # encoding: utf-8 +from .fraction import Fraction + class Operator(str): """The operator class, is a string (representation of the operator) with its arity""" @@ -30,7 +32,7 @@ class Operator(str): elif self.arity == 2: # C'est moche mais je veux que ça marche... if str(self) == "/": - ans = [Fraction(op1, op2)] + ans = [Fraction(args[0], args[1])] ans += ans[0].simplify() return ans else: diff --git a/test/test_expression.py b/test/test_expression.py index c4126bb..03716d0 100644 --- a/test/test_expression.py +++ b/test/test_expression.py @@ -56,18 +56,6 @@ class TestExpression(unittest.TestCase): exp = "1 + $" self.assertRaises(ValueError, Expression.str2tokens, exp) - def test_doMath(self): - ops = [\ - {"op": ("+", 1 , 2), "res" : 3}, \ - {"op": ("-", 1 , 2), "res" : -1}, \ - {"op": ("*", 1 , 2), "res" : 2}, \ - {"op": ("/", 1 , 2), "res" : Fraction(1,2)}, \ - {"op": ("^", 1 , 2), "res" : 1}, \ - ] - for op in ops: - res = first_elem(Expression.doMath(*op["op"])) - self.assertAlmostEqual(res, op["res"]) - def test_isNumber(self): pass