def map_call(self, expr): if isinstance(expr.function, prim.Variable) \ and expr.function.name == "bessel_j": order, arg = expr.parameters self.rec(arg) assert isinstance(order, int) self.bessel_j_arg_to_top_order[arg] = max( self.bessel_j_arg_to_top_order.get(arg, 0), abs(order)) else: return WalkMapper.map_call(self, expr)
def test_mappers(): from pymbolic import variables f, x, y, z = variables("f x y z") for expr in [f(x, (y, z), name=z**2)]: from pymbolic.mapper import WalkMapper from pymbolic.mapper.dependency import DependencyMapper str(expr) IdentityMapper()(expr) WalkMapper()(expr) DependencyMapper()(expr)