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

Public Member Functions

def evaluate
 
- Public Member Functions inherited from CellMLToNektar.pycml.mathml_operator
def wrong_number_of_operands
 
- Public Member Functions inherited from CellMLToNektar.pycml.mathml
def __init__
 
def __repr__
 
def __deepcopy__
 
def clone_self
 
def get_original_of_clone
 
def get_component
 
def model
 
def eval
 
- Public Member Functions inherited from CellMLToNektar.pycml.element_base
def __init__
 
def __delattr__
 
def __setattr__
 
def rootNode
 
def cmeta_id
 
def xml_remove_child_at
 
def xml_doc
 
def xml_properties
 

Private Member Functions

def _set_in_units
 

Additional Inherited Members

- Static Public Member Functions inherited from CellMLToNektar.pycml.mathml
def clone
 
- 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 <root> operator.

Definition at line 5760 of file pycml.py.

Member Function Documentation

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

Set the degree to have units of dimensionless, and the operand to
have an arbitrary member of its possible units set.

Where these mean the <apply> doesn't have the given units, wrap it
in suitable units conversion mathematics.

Definition at line 5762 of file pycml.py.

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

5763  def _set_in_units(self, units, no_act=False):
5764  """Set the units of the application of this operator.
5765 
5766  Set the degree to have units of dimensionless, and the operand to
5767  have an arbitrary member of its possible units set.
5768 
5769  Where these mean the <apply> doesn't have the given units, wrap it
5770  in suitable units conversion mathematics.
5771  """
5772  app = self.xml_parent
5773  defn_units_set = app.get_units()
5774  defn_units = defn_units_set.extract()
5775  app._add_units_conversion(app, defn_units, units, no_act)
5776  # Record which member of the set we used
5777  if not no_act:
5778  app._cml_units = defn_units
5779  # Set degree units
5780  if hasattr(app, u'degree'):
5781  dimensionless = app.model.get_units_by_name('dimensionless')
5782  self._set_element_in_units(_child1(app.degree), dimensionless, no_act)
5783  # Set operand units
5784  for src_units_set, src_units in defn_units_set._get_sources(defn_units):
5785  expr = src_units_set.get_expression()
5786  self._set_element_in_units(expr, src_units, no_act)
def CellMLToNektar.pycml.mathml_root.evaluate (   self)
Return the operand to the given degree, if present.
Otherwise return the square root of the operand.

Definition at line 5787 of file pycml.py.

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

Referenced by CellMLToNektar.pycml.mathml_constructor._eval_self().

5788  def evaluate(self):
5789  """
5790  Return the operand to the given degree, if present.
5791  Otherwise return the square root of the operand.
5792  """
5793  app = self.xml_parent
5794  ops = list(app.operands())
5795  if len(ops) != 1:
5796  self.wrong_number_of_operands(len(ops), [1])
5797  if hasattr(app, u'degree'):
5798  degree = self.eval(app.degree)
5799  else:
5800  degree = 2
5801  return self.eval(ops[0]) ** (1/degree)