Nektar++
Public Member Functions | Public Attributes | List of all members
CellMLToNektar.optimize.ExpressionMatcher.R Class Reference
Inheritance diagram for CellMLToNektar.optimize.ExpressionMatcher.R:
[legend]

Public Member Functions

def __init__ (self, pat)
 
def match (self, expr)
 
def match (self, expr)
 

Public Attributes

 sub_pattern
 

Detailed Description

A container that matches any number of levels of indirection/recursion.

This can be used to wrap a pattern where we wish to allow for variable mappings
or equations such as "var1 = var2" before we reach the 'interesting' equation.
If the expression we're matching is a ci element we recursively find the
ultimate non-ci defining expression and match our sub-pattern against that.  If
the expression isn't a ci, or the ultimate definition isn't an expression, we
match our sub-pattern against it directly.

Definition at line 1401 of file optimize.py.

Constructor & Destructor Documentation

◆ __init__()

def CellMLToNektar.optimize.ExpressionMatcher.R.__init__ (   self,
  pat 
)

Definition at line 1411 of file optimize.py.

1411 def __init__(self, pat):
1412 self.sub_pattern = pat
1413

Member Function Documentation

◆ match()

def CellMLToNektar.optimize.ExpressionMatcher.R.match (   self,
  expr 
)
Method implemented by concrete subclasses to test a given expression.
Returns True iff there is a match.

Reimplemented from CellMLToNektar.optimize.ExpressionMatcher.Pattern.

Definition at line 1414 of file optimize.py.

1414 def match(self, expr):
1415 while isinstance(expr, mathml_ci):
1416 # Find this variable's defining expression, if it is an equation
1417 var = expr.variable.get_source_variable(recurse=True)
1418 defn = var.get_dependencies()
1419 if defn and isinstance(defn[0], mathml_apply):
1420 expr = defn[0].eq.rhs
1421 return self.sub_pattern.match(expr)
1422
1423 @staticmethod

References CellMLToNektar.optimize.ExpressionMatcher.R.match(), and CellMLToNektar.optimize.ExpressionMatcher.R.sub_pattern.

Referenced by CellMLToNektar.optimize.ExpressionMatcher.R.match().

Member Data Documentation

◆ sub_pattern

CellMLToNektar.optimize.ExpressionMatcher.R.sub_pattern

Definition at line 1412 of file optimize.py.

Referenced by CellMLToNektar.optimize.ExpressionMatcher.R.match().