diff --git a/src/functions.py b/src/functions.py index e7ee6719f7abe89d1a2e9e7e4be2aa2cfd6f2f03..b5e110b10de8bcc740b4596b077c54f0ebd2e4ad 100644 --- a/src/functions.py +++ b/src/functions.py @@ -4,13 +4,13 @@ import pymbolic.primitives as primitives def sin(x): - return primitives.Call(primitives.ElementLookup(primitives.Variable("math"), "sin"), (x,)) + return primitives.Call(primitives.Lookup(primitives.Variable("math"), "sin"), (x,)) def cos(x): - return primitives.Call(primitives.ElementLookup(primitives.Variable("math"), "cos"), (x,)) + return primitives.Call(primitives.Lookup(primitives.Variable("math"), "cos"), (x,)) def tan(x): - return primitives.Call(primitives.ElementLookup(primitives.Variable("math"), "tan"), (x,)) + return primitives.Call(primitives.Lookup(primitives.Variable("math"), "tan"), (x,)) def log(x): - return primitives.Call(primitives.ElementLookup(primitives.Variable("math"), "log"), (x,)) + return primitives.Call(primitives.Lookup(primitives.Variable("math"), "log"), (x,)) def exp(x): - return primitives.Call(primitives.ElementLookup(primitives.Variable("math"), "exp"), (x,)) + return primitives.Call(primitives.Lookup(primitives.Variable("math"), "exp"), (x,)) diff --git a/src/mapper/differentiator.py b/src/mapper/differentiator.py index e19edc3dadbc9585621f1785540e1b59565afa0f..8f613f54ffae3ad04258e1a4debedaf9c7981b4e 100644 --- a/src/mapper/differentiator.py +++ b/src/mapper/differentiator.py @@ -15,7 +15,7 @@ def map_math_functions_by_name(i, func, pars): raise RuntimeError, "No derivative of non-constant function "+str(func) def make_f(name): - return primitives.ElementLookup(primitives.Variable("math"), name) + return primitives.Lookup(primitives.Variable("math"), name) if f is math.sin and len(pars) == 1: return make_f("cos")(*pars) diff --git a/src/parser.py b/src/parser.py index f7a7e384997ba7a4e91c27a475da34bd1cd3390e..cb77d3c02951cbd690e109b73898eac96a86fe90 100644 --- a/src/parser.py +++ b/src/parser.py @@ -112,7 +112,7 @@ def parse(expr_str): elif next_tag is _dot and _PREC_CALL > min_precedence: pstate.advance() pstate.expect(_identifier) - left_exp = primitives.ElementLookup(left_exp, pstate.next_str()) + left_exp = primitives.Lookup(left_exp, pstate.next_str()) pstate.advance() did_something = True elif next_tag is _plus and _PREC_PLUS > min_precedence: diff --git a/src/primitives.py b/src/primitives.py index 976baf78b6815c77daf911557aba3e2655b3c6c3..d139bbb1f4ee097b3c3fb9deadb00c00b4cf42de 100644 --- a/src/primitives.py +++ b/src/primitives.py @@ -237,7 +237,7 @@ class Subscript(AlgebraicLeaf): -class ElementLookup(AlgebraicLeaf): +class Lookup(AlgebraicLeaf): def __init__(self, aggregate, name): self.aggregate = aggregate self.name = name @@ -246,7 +246,7 @@ class ElementLookup(AlgebraicLeaf): return self.aggregate, self.name def __eq__(self, other): - return isinstance(other, ElementLookup) \ + return isinstance(other, Lookup) \ and (self.aggregate == other.aggregate) \ and (self.name == other.name) @@ -426,7 +426,7 @@ class Power(Expression): # intelligent makers --------------------------------------------------------- def make_variable(var_or_string): - if not isinstance(var_or_string, Variable): + if not isinstance(var_or_string, Expression): return Variable(var_or_string) else: return var_or_string