From 316b8bf52bcafeda47c1edd6f9a6dcf3b551ddc0 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sat, 28 Feb 2015 23:11:04 +0100 Subject: [PATCH] mod all ini_step in Polynom. It solve bug with eval poly --- pymath/polynom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pymath/polynom.py b/pymath/polynom.py index 1a79843..1355e0d 100644 --- a/pymath/polynom.py +++ b/pymath/polynom.py @@ -434,7 +434,7 @@ class Polynom(Explicable): n_coef = spe_zip(self._coef, o_poly._coef) p = Polynom(n_coef, letter = self._letter) - ini_step = [Expression(self.postfix_tokens) + Expression(o_poly.postfix_tokens)] + ini_step = [Expression(self.postfix_tokens + o_poly.postfix_tokens + [op.add])] ans = p.simplify() ans.steps = ini_step + ans.steps return ans @@ -453,7 +453,7 @@ class Polynom(Explicable): >>> Q.steps [< [3, 'x', 2, '^', '*', 2, 'x', '*', '+', 1, '+', '-'] >] """ - ini_step = [- Expression(self.postfix_tokens)] + ini_step = [Expression(self.postfix_tokens + [op.sub1])] ans = Polynom([-i for i in self._coef], letter = self._letter).simplify() ans.steps = ini_step + ans.steps return ans @@ -470,7 +470,7 @@ class Polynom(Explicable): [< [3, 'x', 2, '^', '*', 2, 'x', '*', '+', 1, '+', 6, 'x', 2, '^', '*', 5, 'x', '*', '+', 4, '+', '-'] >, < [3, 'x', 2, '^', '*', 2, 'x', '*', '+', 1, '+', 6, 'x', 2, '^', '*', '-', 5, 'x', '*', '-', 4, '-', '+'] >, < Polynom [< [1, -4, '+'] >, < [2, -5, '+'] >, < [3, -6, '+'] >]>, < Polynom [< [1, -4, '+'] >, < [2, -5, '+'] >, < [3, -6, '+'] >]>] """ o_poly = self.conv2poly(other) - ini_step = [Expression(self.postfix_tokens) - Expression(o_poly.postfix_tokens)] + ini_step = [Expression(self.postfix_tokens + o_poly.postfix_tokens + [op.sub])] o_poly = -o_poly #ini_step += o_poly.steps @@ -566,7 +566,7 @@ class Polynom(Explicable): if not type(power): raise ValueError("Can't raise Polynom to {} power".format(str(power))) - ini_step = [Expression(self.postfix_tokens) ^ power] + ini_step = [Expression(self.postfix_tokens + [power, op.pw])] if self.is_monom(): if self._coef[self.degree] == 1: