solve bug with simplify fraction (which has not be simplified)

This commit is contained in:
Lafrite 2014-12-21 15:03:56 +01:00
parent 2425a2dfca
commit 027a3ac57a

View File

@ -231,10 +231,9 @@ class Polynom(object):
else: else:
coef_steps = [coef] coef_steps = [coef]
try: try:
coef_steps.append(coef.simplify()) coef_steps += coef.simplify()
except AttributeError: except AttributeError:
pass pass
# On ajoute toutes ces étapes # On ajoute toutes ces étapes
coefs_steps.append(coef_steps) coefs_steps.append(coef_steps)
@ -327,6 +326,8 @@ class Polynom(object):
steps.append(p) steps.append(p)
steps += p.simplify() steps += p.simplify()
#print("steps -> \n", "\n".join(["\t {}".format(s._coef) for s in steps]))
return steps return steps
@ -346,26 +347,29 @@ def test(p,q):
print(p, "+", q) print(p, "+", q)
for i in (p + q): for i in (p + q):
#print(repr(i)) #print(repr(i))
#print("\t", str(i.postfix)) print("\t", str(i.postfix))
print(i) print(i)
#print((p+q)[-1]._coef)
print("\n Moins ------") print("\n Moins ------")
for i in (p - q): for i in (p - q):
#print(repr(i)) #print(repr(i))
#print("\t", str(i.postfix)) #print("\t", str(i.postfix))
print(i) print(i)
#print((p-q)[-1]._coef)
print("\n Multiplier ------") print("\n Multiplier ------")
for i in (p * q): for i in (p * q):
#print(repr(i)) #print(repr(i))
#print("\t", str(i.postfix)) #print("\t", str(i.postfix))
print(i) print(i)
#print((p*q)[-1]._coef)
if __name__ == '__main__': if __name__ == '__main__':
from .fraction import Fraction from .fraction import Fraction
p = Polynom([1, -2 ]) p = Polynom([1, -2 ])
q = Polynom([4, 7]) q = Polynom([4, 7, 4])
test(p,q) test(p,q)
q = Polynom([0, Fraction(1,2), 0, Fraction(-4,3)]) q = Polynom([0, Fraction(1,2), 0, Fraction(-4,3)])