Feat: make MOFraction comparable
This commit is contained in:
parent
78ce8f767a
commit
bf55470467
@ -269,7 +269,8 @@ class Fraction(Token):
|
||||
>>> f.decimal
|
||||
<Decimal 0.3333333333333333333333333333>
|
||||
"""
|
||||
return Decimal(_Decimal(self._mo.numerator._value) / _Decimal(self._mo.denominator._value))
|
||||
return Decimal(self._mo._value)
|
||||
|
||||
|
||||
|
||||
# -----------------------------
|
||||
|
@ -9,6 +9,7 @@
|
||||
from mapytex.calculus.core.tree import Tree
|
||||
from .mo import Molecule, MO
|
||||
from .atoms import MOnumber
|
||||
from decimal import Decimal
|
||||
|
||||
__all__ = ["MOFraction"]
|
||||
|
||||
@ -70,6 +71,10 @@ class MOFraction(Molecule):
|
||||
def denominator(self):
|
||||
return self._denominator
|
||||
|
||||
@property
|
||||
def _value(self):
|
||||
return Decimal(self._numerator._value) / Decimal(self._denominator._value)
|
||||
|
||||
def inverse(self):
|
||||
""" return the inverse fraction """
|
||||
return MOFraction(self._denominator, self._numerator, self.negative)
|
||||
|
Loading…
Reference in New Issue
Block a user