Feat: start working on eval for polynoms
This commit is contained in:
parent
1ed0b9715a
commit
071b8caf1d
@ -18,7 +18,13 @@ __all__ = ["Polynomial", "Quadratic", "Linear"]
|
||||
|
||||
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):
|
||||
if not isinstance(a, MO):
|
||||
@ -50,7 +56,13 @@ class Polynomial(Token):
|
||||
pass
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -82,6 +94,17 @@ class Quadratic(Polynomial):
|
||||
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'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue
Block a user