Feat: start working on eval for polynoms
This commit is contained in:
parent
b51ac7880d
commit
0faaf481ca
@ -18,7 +18,13 @@ __all__ = ["Polynomial", "Quadratic", "Linear"]
|
|||||||
|
|
||||||
class Polynomial(Token):
|
class Polynomial(Token):
|
||||||
|
|
||||||
""" Token representing a polynomial """
|
""" Token representing a polynomial
|
||||||
|
|
||||||
|
:examples:
|
||||||
|
>>> from ...core.MO.polynomial import MOpolynomial
|
||||||
|
>>> P = Polynomial(MOpolynomial('x', [1, 2, 3]))
|
||||||
|
>>> P
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, a, name="", ancestor=None):
|
def __init__(self, a, name="", ancestor=None):
|
||||||
if not isinstance(a, MO):
|
if not isinstance(a, MO):
|
||||||
@ -50,7 +56,13 @@ class Polynomial(Token):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def __call__(self, value):
|
def __call__(self, value):
|
||||||
""" Call a Polynomial to evaluate itself on value """
|
""" Call a Polynomial to evaluate itself on value
|
||||||
|
|
||||||
|
:examples:
|
||||||
|
>>> from ...core.MO.polynomial import MOpolynomial
|
||||||
|
>>> P = Polynomial(MOpolynomial('x', [1, 2, 3]))
|
||||||
|
>>> P(2)
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +94,17 @@ class Quadratic(Polynomial):
|
|||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|
||||||
|
|
||||||
|
def extract_variable(leaf):
|
||||||
|
try:
|
||||||
|
return leaf.variable
|
||||||
|
except AttributeError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def replace(leaf, origin, dest):
|
||||||
|
# map_on_leaf sur leaf?
|
||||||
|
if leaf == origin:
|
||||||
|
return dest
|
||||||
|
return leaf
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Reglages pour 'vim'
|
# Reglages pour 'vim'
|
||||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||||
|
Loading…
Reference in New Issue
Block a user