Feat(Core): add coefficients property to MOstr, MOstrPower, MOMonomial
This commit is contained in:
parent
bcf589c607
commit
cad6cd7182
@ -255,6 +255,19 @@ class MOstr(MO):
|
||||
def variable(self):
|
||||
return self._variable
|
||||
|
||||
@property
|
||||
def coefficients(self):
|
||||
""" Dictionnary of coefficients
|
||||
|
||||
:example:
|
||||
>>> p = MOstr("x")
|
||||
>>> p.coefficients
|
||||
{1: <MOnumber 1>}
|
||||
"""
|
||||
|
||||
return {1: MOnumber(1)}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
|
@ -66,6 +66,19 @@ class MOstrPower(MO):
|
||||
|
||||
MO.__init__(self, _tree)
|
||||
|
||||
|
||||
@property
|
||||
def coefficients(self):
|
||||
""" Dictionnary of coefficients
|
||||
|
||||
:example:
|
||||
>>> p = MOstrPower("x", 2)
|
||||
>>> p.coefficients
|
||||
{2: <MOnumber 1>}
|
||||
"""
|
||||
|
||||
return {self.power.value: MOnumber(1)}
|
||||
|
||||
@property
|
||||
def variable(self):
|
||||
return self._variable
|
||||
@ -150,6 +163,18 @@ class MOMonomial(MO):
|
||||
def coefficient(self):
|
||||
return self._coefficient
|
||||
|
||||
@property
|
||||
def coefficients(self):
|
||||
""" Dictionnary of coefficients
|
||||
|
||||
:example:
|
||||
>>> p = MOMonomial(3, "x", 2)
|
||||
>>> p.coefficients
|
||||
{2: <MOnumber 3>}
|
||||
"""
|
||||
|
||||
return {self.power.value: self._coefficient}
|
||||
|
||||
@property
|
||||
def strpower(self):
|
||||
if self._power == 1:
|
||||
|
Loading…
Reference in New Issue
Block a user