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

Private Member Functions

def _set_in_units (self, units, no_act=False)
 

Detailed Description

Definition at line 3588 of file pycml.py.

Member Function Documentation

◆ _set_in_units()

def CellMLToNektar.pycml.mathml_units_mixin_equalise_operands._set_in_units (   self,
  units,
  no_act = False 
)
private
Set the units of the application of this operator.

This method is used for the relational operators.  It ignores the
given units, and instead ensures that all operands have the same
units.  The units it chooses are those that are 'least' amongst the
possibilities for the operand units, i.e. that have the smallest
multiplicative factor when expanded.

Reimplemented in CellMLToNektar.pycml.mathml_eq.

Definition at line 3589 of file pycml.py.

3589 def _set_in_units(self, units, no_act=False):
3590 """Set the units of the application of this operator.
3591
3592 This method is used for the relational operators. It ignores the
3593 given units, and instead ensures that all operands have the same
3594 units. The units it chooses are those that are 'least' amongst the
3595 possibilities for the operand units, i.e. that have the smallest
3596 multiplicative factor when expanded.
3597 """
3598 app = self.xml_parent
3599 min_factor, operand_units = None, None
3600 for us in app._get_operand_units():
3601 if isinstance(us, cellml_units):
3602 us = [us]
3603 for u in us:
3604 f = u.expand().get_multiplicative_factor()
3605 if f < min_factor or min_factor is None:
3606 min_factor = f
3607 operand_units = u
3608 # We need to convert the operands to a list, because the tree
3609 # may be modified if a conversion is thought to be needed
3610 for operand in list(app.operands()):
3611 # TODO: Modify tree to collect same conversions together?
3612 self._set_element_in_units(operand, operand_units, no_act)
3613 # And set our units to what they now are
3614 if not no_act:
3615 app._cml_units = units
3616 return
3617
def get_multiplicative_factor(self)
Definition: pycml.py:2876

References CellMLToNektar.pycml.mathml_units_mixin._set_element_in_units(), and CellMLToNektar.pycml.get_multiplicative_factor().