Adapt Polynom with Expression.tmp_render env
This commit is contained in:
parent
48c2c1dc78
commit
8881a15c9b
@ -291,19 +291,15 @@ class Polynom(object):
|
|||||||
# On converti en Expression
|
# On converti en Expression
|
||||||
coef_exp = Expression(postfix_add)
|
coef_exp = Expression(postfix_add)
|
||||||
|
|
||||||
old_render = Expression.get_render()
|
with Expression.tmp_render():
|
||||||
Expression.set_render(lambda _,x:Expression(x))
|
coef_steps = list(coef_exp.simplify())
|
||||||
coef_steps = list(coef_exp.simplify())
|
|
||||||
Expression.set_render(old_render)
|
|
||||||
|
|
||||||
#print('\t 1.coef_steps -> ', coef_steps)
|
#print('\t 1.coef_steps -> ', coef_steps)
|
||||||
|
|
||||||
elif type(coef) == Expression:
|
elif type(coef) == Expression:
|
||||||
|
|
||||||
old_render = Expression.get_render()
|
with Expression.tmp_render():
|
||||||
Expression.set_render(lambda _,x:Expression(x))
|
coef_steps = list(coef.simplify())
|
||||||
coef_steps = list(coef.simplify())
|
|
||||||
Expression.set_render(old_render)
|
|
||||||
|
|
||||||
#print('\t 2.coef_steps -> ', coef_steps)
|
#print('\t 2.coef_steps -> ', coef_steps)
|
||||||
|
|
||||||
@ -524,12 +520,12 @@ def test(p,q):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#from .fraction import Fraction
|
#from .fraction import Fraction
|
||||||
Expression.set_render(txt)
|
with Expression.tmp_render(txt):
|
||||||
p = Polynom([10, -5])
|
p = Polynom([10, -5])
|
||||||
q = Polynom([3, -9])
|
q = Polynom([3, -9])
|
||||||
print(p-q)
|
print(p-q)
|
||||||
for i in p-q:
|
for i in p-q:
|
||||||
print(i)
|
print(i)
|
||||||
|
|
||||||
|
|
||||||
import doctest
|
import doctest
|
||||||
|
Loading…
Reference in New Issue
Block a user