try evaluate polynoms with other polynoms
This commit is contained in:
parent
f6739f8c7c
commit
d5d889eeb0
@ -68,7 +68,11 @@ class Polynom(object):
|
|||||||
:returns: Expression ready to be simplify
|
:returns: Expression ready to be simplify
|
||||||
|
|
||||||
"""
|
"""
|
||||||
postfix_exp = [value if i==self._letter else i for i in self.postfix]
|
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)
|
return Expression(postfix_exp)
|
||||||
|
|
||||||
def feed_coef(self, l_coef):
|
def feed_coef(self, l_coef):
|
||||||
|
@ -43,6 +43,10 @@ class TestPolynom(unittest.TestCase):
|
|||||||
p = Polynom([-1])
|
p = Polynom([-1])
|
||||||
self.assertEqual(p(3).simplified(), -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):
|
#def test_print(self):
|
||||||
# p = Polynom([1,2,3])
|
# p = Polynom([1,2,3])
|
||||||
# ans = "1 + 2 x + 3 x^2"
|
# ans = "1 + 2 x + 3 x^2"
|
||||||
|
Loading…
Reference in New Issue
Block a user