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

Public Member Functions

def evaluate (self)
 
- Public Member Functions inherited from CellMLToNektar.pycml.mathml_operator
def wrong_number_of_operands (self, found, wanted)
 
- Public Member Functions inherited from CellMLToNektar.pycml.mathml
def __init__ (self)
 
def __repr__ (self)
 
def __deepcopy__ (self, memo)
 
def clone_self (self, register=False)
 
def get_original_of_clone (self)
 
def get_component (self)
 
def model (self)
 
def eval (self, elt)
 
- Public Member Functions inherited from CellMLToNektar.pycml.element_base
def __init__ (self)
 
def __delattr__ (self, key)
 
def __setattr__ (self, key, value)
 
def rootNode (self)
 
def cmeta_id (self)
 
def xml_remove_child_at (self, index=-1)
 
def xml_doc (self)
 
def xml_properties (self)
 

Private Member Functions

def _reduce (self)
 

Additional Inherited Members

- Static Public Member Functions inherited from CellMLToNektar.pycml.mathml
def clone (expr)
 
- Public Attributes inherited from CellMLToNektar.pycml.element_base
 xml_attributes
 
- Properties inherited from CellMLToNektar.pycml.mathml
 component = property(get_component)
 

Detailed Description

Class representing the MathML <divide> operator.

Definition at line 5600 of file pycml.py.

Member Function Documentation

◆ _reduce()

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

If the whole expression is static, proceed as normal for an
<apply>.  If just the denominator is static, transform the
expression into a multiplication.

Definition at line 5612 of file pycml.py.

5612 def _reduce(self):
5613 """Reduce this expression by evaluating its static parts.
5614
5615 If the whole expression is static, proceed as normal for an
5616 <apply>. If just the denominator is static, transform the
5617 expression into a multiplication.
5618 """
5619 app = self.xml_parent
5620 bt = app._get_binding_time()
5621 if bt == BINDING_TIMES.static:
5622 # Evaluate this expression as normal
5623 app._reduce(check_operator=False)
5624 else:
5625 # Check binding time of the denominator
5626 ops = list(app.operands())
5627 if len(ops) != 2:
5628 self.wrong_number_of_operands(len(ops), [2])
5629 bt = app._get_element_binding_time(ops[1])
5630 if bt == BINDING_TIMES.static:
5631 # Create inverse expression and evaluate it
5632 dummy = self.xml_create_element(u'dummy', NSS[u'm'])
5633 app.replace_child(ops[1], dummy)
5634 new_expr = mathml_apply.create_new(
5635 self, u'divide', [(u'1', u'dimensionless'),
5636 ops[1]])
5637 app.replace_child(dummy, new_expr)
5638 app._reduce_elt(new_expr)
5639 # Change this expression to a <times>
5640 times = self.xml_create_element(u'times', NSS[u'm'])
5641 app.replace_child(self, times)
5642 # And finally reduce it as normal
5643 app._reduce(check_operator=False)
5644 else:
5645 # Evaluate this expression as normal
5646 app._reduce(check_operator=False)
5647

References CellMLToNektar.pycml.mathml_operator.wrong_number_of_operands().

◆ evaluate()

def CellMLToNektar.pycml.mathml_divide.evaluate (   self)
Evaluate by dividing the 2 operands of the enclosing <apply>.

Definition at line 5602 of file pycml.py.

5602 def evaluate(self):
5603 """Evaluate by dividing the 2 operands of the enclosing <apply>."""
5604 app = self.xml_parent
5605 ops = list(app.operands())
5606 if len(ops) != 2:
5607 self.wrong_number_of_operands(len(ops), [2])
5608 numer = self.eval(ops[0])
5609 denom = self.eval(ops[1])
5610 return numer/denom
5611

References CellMLToNektar.pycml.mathml.eval(), and CellMLToNektar.pycml.mathml_operator.wrong_number_of_operands().

Referenced by CellMLToNektar.pycml.mathml_constructor._eval_self(), and CellMLToNektar.pycml.mathml_ci._reduce().