try evaluate polynoms with other polynoms

This commit is contained in:
Lafrite 2014-12-22 10:13:20 +01:00
parent f6739f8c7c
commit d5d889eeb0
2 changed files with 9 additions and 1 deletions

View File

@ -68,7 +68,11 @@ class Polynom(object):
:returns: Expression ready to be simplify
"""
if isNumber(value):
postfix_exp = [value if i==self._letter else i for i in self.postfix]
else:
postfix_exp = [Expression(value) if i==self._letter else i for i in self.postfix]
return Expression(postfix_exp)
def feed_coef(self, l_coef):

View File

@ -43,6 +43,10 @@ class TestPolynom(unittest.TestCase):
p = Polynom([-1])
self.assertEqual(p(3).simplified(), -1)
def test_eval_poly(self):
p = Polynom([1, 2])
self.assertEqual(p("1+h").simplified(), Polynom([3,2]))
#def test_print(self):
# p = Polynom([1,2,3])
# ans = "1 + 2 x + 3 x^2"