From a564708a315583d6d5e52c94a2233c152a374205 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Sat, 12 Mar 2016 06:10:28 +0300 Subject: [PATCH] Abs_poly handle 2var poly. Need to adapt Poly know --- pymath/calculus/abstract_polynom.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pymath/calculus/abstract_polynom.py b/pymath/calculus/abstract_polynom.py index e3ad516..03eb601 100644 --- a/pymath/calculus/abstract_polynom.py +++ b/pymath/calculus/abstract_polynom.py @@ -275,7 +275,6 @@ class AbstractPolynom(Explicable): pstfx = postfix_op(raw_coefs[::-1], op.add) return flatten_list(pstfx) - def conv2poly(self, other): """Convert anything number into a polynom @@ -284,10 +283,18 @@ class AbstractPolynom(Explicable): < AbstractPolynom x [1]> >>> P.conv2poly(0) < AbstractPolynom x [0]> - + >>> Q = AbstractPolynom([3, 2, 1], 'x') + >>> P.conv2poly(Q) + < AbstractPolynom x [3, 2, 1]> + >>> Q = AbstractPolynom([3, 2, 1], 'y') + >>> P.conv2poly(Q) + < AbstractPolynom x [< AbstractPolynom y [3, 2, 1]>]> """ - if isNumber(other) and not isPolynom(other): - return AbstractPolynom([other], letter=self._letter) + if (isNumber(other) and not isPolynom(other)) or \ + (isPolynom(other) and self._letter != other._letter): + ans = self.__class__([other], letter=self._letter) + ans.steal_history(other) + return ans elif isPolynom(other): return other else: