From b0ff919693ef1012e351504c8a2efd1d06b34515 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Thu, 15 Mar 2018 16:38:25 +0300 Subject: [PATCH] synthtize comparison for MOnumber --- mapytex/calculus/core/MO/mo.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/mapytex/calculus/core/MO/mo.py b/mapytex/calculus/core/MO/mo.py index b15242f..7f01193 100644 --- a/mapytex/calculus/core/MO/mo.py +++ b/mapytex/calculus/core/MO/mo.py @@ -10,6 +10,7 @@ from decimal import Decimal from .exceptions import MOError from ..coroutine import coroutine, STOOOP from ..renders import tree2txt, tree2tex +from functools import total_ordering __all__ = ["moify", "MO", "MOstr"] @@ -116,6 +117,7 @@ class MO(object): return str(self.value) +@total_ordering class MOnumber(MO): """ Base number math object (int or Decimal) """ @@ -266,27 +268,6 @@ class MOnumber(MO): except AttributeError: return self.value < other - def __le__(self, other): - """ <= a MOnumber """ - try: - return self.value <= other.value - except AttributeError: - return self.value <= other - - def __gt__(self, other): - """ > a MOnumber """ - try: - return self.value > other.value - except AttributeError: - return self.value > other - - def __ge__(self, other): - """ >= a MOnumber """ - try: - return self.value >= other.value - except AttributeError: - return self.value >= other - def __hash__(self): return self.value.__hash__()