loki.transformations.sanitise.substitute
Classes
A |
- class SubstituteExpressionTransformation(substitute_expressions=True, expression_map=None, substitute_body=True, substitute_spec=True)
Bases:
Transformation
A
Transformation
that allows individual expressions to be substituted inSubroutine
objects.The expressions should be provided as a dictionary map of strings, which will be parsed in the local
Subroutine
scope to determine the respective symbols.- Parameters:
substitute_expressions (bool) – Flag to trigger or suppress expression substitution
expression_map (dict of str to str) – A string-to-string map detailing the substitutions to apply.
substitute_spec (bool) – Flag to trigger or suppress expression substitution in specs.
substitute_body (bool) – Flag to trigger or suppress expression substitution in bodies.
- transform_subroutine(routine, **kwargs)
Defines the transformation to apply to
Subroutine
items.For transformations that modify
Subroutine
objects, this method should be implemented. It gets called via the dispatch methodapply()
.- Parameters:
routine (
Subroutine
) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.