Nektar++
Private Member Functions | List of all members
CellMLToNektar.pycml.reduce_commutative_nary Class Reference
Inheritance diagram for CellMLToNektar.pycml.reduce_commutative_nary:
[legend]

Private Member Functions

def _reduce (self)
 

Detailed Description

Definition at line 5524 of file pycml.py.

Member Function Documentation

◆ _reduce()

def CellMLToNektar.pycml.reduce_commutative_nary._reduce (   self)
private
Reduce this expression by evaluating its static parts.

If the whole expression is static, proceed as normal for an
<apply>.  Otherwise check if we have more than one static
operand.  If we do, we can combine them in a new static
expression and evaluate that as a whole.

Definition at line 5525 of file pycml.py.

5525 def _reduce(self):
5526 """Reduce this expression by evaluating its static parts.
5527
5528 If the whole expression is static, proceed as normal for an
5529 <apply>. Otherwise check if we have more than one static
5530 operand. If we do, we can combine them in a new static
5531 expression and evaluate that as a whole.
5532 """
5533 app = self.xml_parent
5534 bt = app._get_binding_time()
5535 if bt == BINDING_TIMES.static or not self.model.get_option('partial_pe_commutative'):
5536 # Evaluate this expression as normal
5537 app._reduce(check_operator=False)
5538 else:
5539 # Get binding times of operands
5540 static_opers = filter(lambda e: app._get_element_binding_time(e) == BINDING_TIMES.static,
5541 app.operands())
5542 if len(static_opers) > 1:
5543 # Remove them from app
5544 for oper in static_opers:
5545 app.safe_remove_child(oper)
5546 # Create the new expression
5547 new_expr = mathml_apply.create_new(self, self.localName, static_opers)
5548 # Put it in the model and reduce it to evaluate it properly
5549 app.xml_append(new_expr)
5550 new_expr._reduce()
5551 # Now reduce all our operands as normal
5552 app._reduce(check_operator=False)
5553

References CellMLToNektar.processors.ModelModifier.model, CellMLToNektar.pycml.cellml_variable.model(), CellMLToNektar.pycml.mathml.model(), and CellMLToNektar.translators.CellMLTranslator.model.