All tests pass :D
This commit is contained in:
parent
7987f3f1be
commit
64d5bed8fe
@ -307,6 +307,11 @@ class AbstractPolynom(Explicable):
|
|||||||
>>> Q = P.reduce()
|
>>> Q = P.reduce()
|
||||||
>>> Q
|
>>> Q
|
||||||
< <class 'pymath.abstract_polynom.AbstractPolynom'> [3, 12, 6]>
|
< <class 'pymath.abstract_polynom.AbstractPolynom'> [3, 12, 6]>
|
||||||
|
>>> for i in Q.explain():
|
||||||
|
... print(i)
|
||||||
|
6 x^{ 2 } + ( 3 + 4 + 5 ) x + 1 + 2
|
||||||
|
6 x^{ 2 } + ( 7 + 5 ) x + 3
|
||||||
|
6 x^{ 2 } + 12 x + 3
|
||||||
>>> Q.steps
|
>>> Q.steps
|
||||||
[< <class 'pymath.abstract_polynom.AbstractPolynom'> [< <class 'pymath.expression.Expression'> [1, 2, '+'] >, < <class 'pymath.expression.Expression'> [3, 4, '+', 5, '+'] >, 6]>, < <class 'pymath.abstract_polynom.AbstractPolynom'> [3, < <class 'pymath.expression.Expression'> [7, 5, '+'] >, 6]>]
|
[< <class 'pymath.abstract_polynom.AbstractPolynom'> [< <class 'pymath.expression.Expression'> [1, 2, '+'] >, < <class 'pymath.expression.Expression'> [3, 4, '+', 5, '+'] >, 6]>, < <class 'pymath.abstract_polynom.AbstractPolynom'> [3, < <class 'pymath.expression.Expression'> [7, 5, '+'] >, 6]>]
|
||||||
"""
|
"""
|
||||||
@ -580,6 +585,14 @@ class AbstractPolynom(Explicable):
|
|||||||
def __xor__(self, power):
|
def __xor__(self, power):
|
||||||
return self.__pow__(power)
|
return self.__pow__(power)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
P = AbstractPolynom([[1,2],[3,4,5],6])
|
||||||
|
Q = P.reduce()
|
||||||
|
for i in Q.explain():
|
||||||
|
print(i)
|
||||||
|
|
||||||
|
#import doctest
|
||||||
|
#doctest.testmod()
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
from .render import txt, tex
|
from .render import txt, tex
|
||||||
|
|
||||||
class Renderable(object):
|
class Renderable(object):
|
||||||
|
"""
|
||||||
|
A Renderable object is an object which can work with Render class. It means that it has to have attribute postfix_tokens.
|
||||||
|
"""
|
||||||
STR_RENDER = tex
|
STR_RENDER = tex
|
||||||
DEFAULT_RENDER = tex
|
DEFAULT_RENDER = tex
|
||||||
|
|
||||||
@ -60,6 +63,15 @@ class Renderable(object):
|
|||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, type, value, traceback):
|
||||||
Renderable.set_render(self.old_render)
|
Renderable.set_render(self.old_render)
|
||||||
return TmpRenderEnv()
|
return TmpRenderEnv()
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
""" Two Renderable objects are the same if they have same postfix_tokens """
|
||||||
|
try:
|
||||||
|
return self.postfix_tokens == other.postfix_tokens
|
||||||
|
except AttributeError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Explicable(Renderable):
|
class Explicable(Renderable):
|
||||||
|
|
||||||
|
@ -350,11 +350,11 @@ def untest(exp):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#print('\n')
|
#print('\n')
|
||||||
A = Expression("( -8 x + 8 ) ( -8 - ( -6 x ) )")
|
#A = Expression("( -8 x + 8 ) ( -8 - ( -6 x ) )")
|
||||||
Ar = A.simplify()
|
#Ar = A.simplify()
|
||||||
#print("Ar.steps -> ", Ar.steps)
|
#print("Ar.steps -> ", Ar.steps)
|
||||||
for i in Ar.explain():
|
#for i in Ar.explain():
|
||||||
print(i)
|
# print(i)
|
||||||
#print("------------")
|
#print("------------")
|
||||||
#for i in Ar.explain():
|
#for i in Ar.explain():
|
||||||
# print(i)
|
# print(i)
|
||||||
@ -362,20 +362,20 @@ if __name__ == '__main__':
|
|||||||
#print(type(Ar))
|
#print(type(Ar))
|
||||||
|
|
||||||
|
|
||||||
print('\n-----------')
|
#print('\n-----------')
|
||||||
A = Expression("2 / 3 + 4 / 5")
|
#A = Expression("2 / 3 + 4 / 5")
|
||||||
Ar = A.simplify()
|
#Ar = A.simplify()
|
||||||
#print("Ar.steps -> ", Ar.steps)
|
#print("Ar.steps -> ", Ar.steps)
|
||||||
#for i in Ar.steps:
|
#for i in Ar.steps:
|
||||||
# print(i)
|
# print(i)
|
||||||
#print("------------")
|
#print("------------")
|
||||||
for i in Ar.explain():
|
#for i in Ar.explain():
|
||||||
print(i)
|
# print(i)
|
||||||
|
|
||||||
#print(type(Ar))
|
#print(type(Ar))
|
||||||
|
|
||||||
#import doctest
|
import doctest
|
||||||
#doctest.testmod()
|
doctest.testmod()
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Reglages pour 'vim'
|
# Reglages pour 'vim'
|
||||||
|
Loading…
Reference in New Issue
Block a user