All tests pass :D
This commit is contained in:
parent
3589a2733a
commit
d9744cbcae
@ -307,6 +307,11 @@ class AbstractPolynom(Explicable):
|
||||
>>> Q = P.reduce()
|
||||
>>> Q
|
||||
< <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
|
||||
[< <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):
|
||||
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
|
||||
|
||||
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
|
||||
DEFAULT_RENDER = tex
|
||||
|
||||
@ -61,6 +64,15 @@ class Renderable(object):
|
||||
Renderable.set_render(self.old_render)
|
||||
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):
|
||||
|
||||
""" An Explicable object is an object which can be explicable!
|
||||
|
@ -350,11 +350,11 @@ def untest(exp):
|
||||
|
||||
if __name__ == '__main__':
|
||||
#print('\n')
|
||||
A = Expression("( -8 x + 8 ) ( -8 - ( -6 x ) )")
|
||||
Ar = A.simplify()
|
||||
#A = Expression("( -8 x + 8 ) ( -8 - ( -6 x ) )")
|
||||
#Ar = A.simplify()
|
||||
#print("Ar.steps -> ", Ar.steps)
|
||||
for i in Ar.explain():
|
||||
print(i)
|
||||
#for i in Ar.explain():
|
||||
# print(i)
|
||||
#print("------------")
|
||||
#for i in Ar.explain():
|
||||
# print(i)
|
||||
@ -362,20 +362,20 @@ if __name__ == '__main__':
|
||||
#print(type(Ar))
|
||||
|
||||
|
||||
print('\n-----------')
|
||||
A = Expression("2 / 3 + 4 / 5")
|
||||
Ar = A.simplify()
|
||||
#print('\n-----------')
|
||||
#A = Expression("2 / 3 + 4 / 5")
|
||||
#Ar = A.simplify()
|
||||
#print("Ar.steps -> ", Ar.steps)
|
||||
#for i in Ar.steps:
|
||||
# print(i)
|
||||
#print("------------")
|
||||
for i in Ar.explain():
|
||||
print(i)
|
||||
#for i in Ar.explain():
|
||||
# print(i)
|
||||
|
||||
#print(type(Ar))
|
||||
|
||||
#import doctest
|
||||
#doctest.testmod()
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
|
Loading…
Reference in New Issue
Block a user