Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Private Member Functions | List of all members
CellMLToNektar.pycml.reduce_commutative_nary Class Reference
Inheritance diagram for CellMLToNektar.pycml.reduce_commutative_nary:
Inheritance graph
[legend]
Collaboration diagram for CellMLToNektar.pycml.reduce_commutative_nary:
Collaboration graph
[legend]

Private Member Functions

def _reduce
 

Detailed Description

Definition at line 5524 of file pycml.py.

Member Function Documentation

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.

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