Abs_poly handle 2var poly. Need to adapt Poly know

This commit is contained in:
Benjamin Bertrand 2016-03-12 06:10:28 +03:00
parent 3abd4e89b5
commit a564708a31
1 changed files with 11 additions and 4 deletions

View File

@ -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: