Feat(Core): Clarify power and degree for MO

This commit is contained in:
Bertrand Benjamin 2018-12-07 15:29:34 +01:00
parent cad6cd7182
commit 8b6ede92c5
3 changed files with 29 additions and 5 deletions

View File

@ -266,6 +266,9 @@ class MOstr(MO):
""" """
return {1: MOnumber(1)} return {1: MOnumber(1)}
@property
def degree(self):
return 1
# ----------------------------- # -----------------------------

View File

@ -85,8 +85,14 @@ class MOstrPower(MO):
@property @property
def power(self): def power(self):
""" MO version """
return self._power return self._power
@property
def degree(self):
""" python version """
return self._power.value
@property @property
def signature(self): def signature(self):
""" Name of the mo in the API """ Name of the mo in the API
@ -190,6 +196,9 @@ class MOMonomial(MO):
return self._power return self._power
@property @property
def degree(self):
return self._power.value
@property
def signature(self): def signature(self):
""" Name of the mo in the API """ Name of the mo in the API

View File

@ -77,18 +77,30 @@ class MOpolynomial(MO):
:example: :example:
>>> p = MOpolynomial('x', [1, 2, 3]) >>> p = MOpolynomial('x', [1, 2, 3])
>>> p.degree >>> p.degree
<MOnumber 2> 2
>>> p = MOpolynomial('x', {0: 1, 3: 4}) >>> p = MOpolynomial('x', {0: 1, 3: 4})
>>> p.degree >>> 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
<MOnumber 2>
>>> p = MOpolynomial('x', {0: 1, 3: 4})
>>> p.power
<MOnumber 3> <MOnumber 3>
""" """
return max(self._coefs.keys()) return max(self._coefs.keys())
@property
def power(self):
return self.degree
@property @property
def coefficients(self): def coefficients(self):
return self._coefs return self._coefs