solve bug#4 can create fraction of fractions
This commit is contained in:
parent
ab0862e10a
commit
a0cf4c1f67
@ -61,6 +61,9 @@ class Fraction(Explicable):
|
|||||||
if self._num == 0:
|
if self._num == 0:
|
||||||
return Expression([0])
|
return Expression([0])
|
||||||
|
|
||||||
|
elif type(self._num) == Fraction or type(self._denom) == Fraction:
|
||||||
|
return self._num / self._denom
|
||||||
|
|
||||||
elif self._denom < 0:
|
elif self._denom < 0:
|
||||||
n_frac = Fraction(-self._num, -self._denom)
|
n_frac = Fraction(-self._num, -self._denom)
|
||||||
ans = n_frac.simplify()
|
ans = n_frac.simplify()
|
||||||
|
@ -176,40 +176,6 @@ for name, func in inspect.getmembers(Polynom):
|
|||||||
setattr(Polynom, name, polynom_factory(func))
|
setattr(Polynom, name, polynom_factory(func))
|
||||||
|
|
||||||
|
|
||||||
def test(p,q):
|
|
||||||
print("---------------------")
|
|
||||||
print("---------------------")
|
|
||||||
print("p : ",p)
|
|
||||||
print("q : ",q)
|
|
||||||
|
|
||||||
print("\n Plus ------")
|
|
||||||
print(p, "+", q)
|
|
||||||
for i in (p + q):
|
|
||||||
#print(repr(i))
|
|
||||||
#print("\t", str(i.postfix_tokens))
|
|
||||||
print(i)
|
|
||||||
|
|
||||||
print("\n Moins ------")
|
|
||||||
for i in (p - q):
|
|
||||||
#print(repr(i))
|
|
||||||
#print("\t", str(i.postfix_tokens))
|
|
||||||
print(i)
|
|
||||||
|
|
||||||
print("\n Multiplier ------")
|
|
||||||
for i in (p * q):
|
|
||||||
#print(repr(i))
|
|
||||||
#print("\t", str(i.postfix_tokens))
|
|
||||||
print(i)
|
|
||||||
|
|
||||||
print("\n Evaluer p ------")
|
|
||||||
for i in p(3).simplify():
|
|
||||||
print(i)
|
|
||||||
|
|
||||||
print("\n Evaluer q ------")
|
|
||||||
for i in q(3).simplify():
|
|
||||||
print(i)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#from .fraction import Fraction
|
#from .fraction import Fraction
|
||||||
#with Expression.tmp_render(txt):
|
#with Expression.tmp_render(txt):
|
||||||
|
Loading…
Reference in New Issue
Block a user