From 8b6ede92c561b39a371313576eb09897ffaaca2c Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Fri, 7 Dec 2018 15:29:34 +0100 Subject: [PATCH] Feat(Core): Clarify power and degree for MO --- mapytex/calculus/core/MO/mo.py | 3 +++ mapytex/calculus/core/MO/monomial.py | 9 +++++++++ mapytex/calculus/core/MO/polynomial.py | 22 +++++++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/mapytex/calculus/core/MO/mo.py b/mapytex/calculus/core/MO/mo.py index 4902f31..c129bd5 100644 --- a/mapytex/calculus/core/MO/mo.py +++ b/mapytex/calculus/core/MO/mo.py @@ -266,6 +266,9 @@ class MOstr(MO): """ return {1: MOnumber(1)} + @property + def degree(self): + return 1 # ----------------------------- diff --git a/mapytex/calculus/core/MO/monomial.py b/mapytex/calculus/core/MO/monomial.py index 392677b..78a4c6e 100644 --- a/mapytex/calculus/core/MO/monomial.py +++ b/mapytex/calculus/core/MO/monomial.py @@ -85,8 +85,14 @@ class MOstrPower(MO): @property def power(self): + """ MO version """ return self._power + @property + def degree(self): + """ python version """ + return self._power.value + @property def signature(self): """ Name of the mo in the API @@ -190,6 +196,9 @@ class MOMonomial(MO): return self._power @property + def degree(self): + return self._power.value + @property def signature(self): """ Name of the mo in the API diff --git a/mapytex/calculus/core/MO/polynomial.py b/mapytex/calculus/core/MO/polynomial.py index cecea32..e454c6a 100644 --- a/mapytex/calculus/core/MO/polynomial.py +++ b/mapytex/calculus/core/MO/polynomial.py @@ -77,18 +77,30 @@ class MOpolynomial(MO): :example: >>> p = MOpolynomial('x', [1, 2, 3]) >>> p.degree - + 2 >>> p = MOpolynomial('x', {0: 1, 3: 4}) >>> p.degree + 3 + + """ + return self.power.value + + @property + def power(self): + """ + Maximum degree of its coefficient + + :example: + >>> p = MOpolynomial('x', [1, 2, 3]) + >>> p.power + + >>> p = MOpolynomial('x', {0: 1, 3: 4}) + >>> p.power """ return max(self._coefs.keys()) - @property - def power(self): - return self.degree - @property def coefficients(self): return self._coefs