Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for CellMLToNektar.pycml.mathml_units_mixin_equalise_operands:
Collaboration graph
[legend]

Private Member Functions

def _set_in_units
 

Detailed Description

Definition at line 3588 of file pycml.py.

Member Function Documentation

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.

Definition at line 3589 of file pycml.py.

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

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