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

Public Member Functions

def __init__
 
def evaluate
 
def get_units
 
- 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
 

Static Public Member Functions

def create_new
 
- Static Public Member Functions inherited from CellMLToNektar.pycml.mathml
def clone
 

Public Attributes

 type
 
- Public Attributes inherited from CellMLToNektar.pycml.element_base
 xml_attributes
 

Private Member Functions

def _get_binding_time
 
def _reduce
 

Private Attributes

 _cml_units
 

Additional Inherited Members

- Properties inherited from CellMLToNektar.pycml.mathml
 component = property(get_component)
 

Detailed Description

Definition at line 4145 of file pycml.py.

Constructor & Destructor Documentation

def CellMLToNektar.pycml.mathml_cn.__init__ (   self)

Definition at line 4146 of file pycml.py.

4147  def __init__(self):
4148  super(mathml_cn, self).__init__()
4149  self._cml_units = None
4150  return

Member Function Documentation

def CellMLToNektar.pycml.mathml_cn._get_binding_time (   self)
private
Return the binding time of this expression.

The binding time of a <cn> element is always static,
unless the CellML is annotated otherwise.

Definition at line 4184 of file pycml.py.

Referenced by CellMLToNektar.pycml.mathml_ci._reduce(), CellMLToNektar.pycml.mathml_apply._reduce(), and CellMLToNektar.pycml.mathml_piecewise._reduce().

4185  def _get_binding_time(self):
4186  """Return the binding time of this expression.
4187 
4188  The binding time of a <cn> element is always static,
4189  unless the CellML is annotated otherwise.
4190  """
4191  bt = self.getAttributeNS(NSS['pe'], u'binding_time', u'static')
4192  return getattr(BINDING_TIMES, bt)
def CellMLToNektar.pycml.mathml_cn._reduce (   self)
private
Reduce this expression by evaluating its static parts.

Is actually a no-op; we must have been annotated explicitly as dynamic.

Definition at line 4193 of file pycml.py.

4194  def _reduce(self):
4195  """Reduce this expression by evaluating its static parts.
4196 
4197  Is actually a no-op; we must have been annotated explicitly as dynamic.
4198  """
4199  return
def CellMLToNektar.pycml.mathml_cn.create_new (   elt,
  value,
  units 
)
static
Create a new <cn> element with the given value and units.

Definition at line 4211 of file pycml.py.

4212  def create_new(elt, value, units):
4213  """Create a new <cn> element with the given value and units."""
4214  attrs = {(u'cml:units', NSS[u'cml']): unicode(units)}
4215  new_elt = elt.xml_create_element(u'cn', NSS[u'm'],
4216  attributes=attrs,
4217  content=unicode(value))
4218  return new_elt
def CellMLToNektar.pycml.mathml_cn.evaluate (   self)
Convert the text content of this element to a floating point
value and return it.  Will handle the type attribute and, if
relevant to the type, the sep child element, but does not yet
handle the base attribute.

Definition at line 4151 of file pycml.py.

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

4152  def evaluate(self):
4153  """
4154  Convert the text content of this element to a floating point
4155  value and return it. Will handle the type attribute and, if
4156  relevant to the type, the sep child element, but does not yet
4157  handle the base attribute.
4158  """
4159  if hasattr(self, u'base'):
4160  raise ValueError('pycml does not yet support the base attribute on cn elements')
4161  if hasattr(self, u'type'):
4162  if self.type == u'real':
4163  val = float(unicode(self))
4164  elif self.type == u'integer':
4165  val = int(unicode(self))
4166  elif self.type == u'e-notation':
4167  assert len(self.xml_children) == 3
4168  assert self.xml_children[1] is self.sep
4169  mantissa = unicode(self.xml_children[0]).strip()
4170  exponent = unicode(self.xml_children[2]).strip()
4171  val = float(mantissa + 'e' + exponent)
4172  elif self.type == u'rational':
4173  assert len(self.xml_children) == 3
4174  assert self.xml_children[1] is self.sep
4175  numer = int(unicode(self.xml_children[0]))
4176  denom = int(unicode(self.xml_children[2]))
4177  val = numer / denom
4178  else:
4179  raise ValueError('Unsupported type attribute for cn element: '
4180  + self.type)
4181  else:
4182  val = float(unicode(self))
4183  return val
def CellMLToNektar.pycml.mathml_cn.get_units (   self,
  return_set = True 
)
Return the units this number is expressed in.

Definition at line 4200 of file pycml.py.

Referenced by CellMLToNektar.pycml.mathml._ensure_units_exist(), CellMLToNektar.pycml.mathml_units_mixin_tokens._set_in_units(), and CellMLToNektar.pycml.mathml_apply._set_in_units().

4201  def get_units(self, return_set=True):
4202  """Return the units this number is expressed in."""
4203  if not self._cml_units:
4204  self._cml_units = UnitsSet([self.component.get_units_by_name(self.units)], expression=self)
4205  if not return_set:
4206  u = self._cml_units.extract()
4207  else:
4208  u = self._cml_units
4209  return u

Member Data Documentation

CellMLToNektar.pycml.mathml_cn._cml_units
private

Definition at line 4148 of file pycml.py.

Referenced by CellMLToNektar.pycml.mathml_apply._set_in_units(), CellMLToNektar.pycml.mathml_piecewise._set_in_units(), CellMLToNektar.pycml.mathml_apply.get_units(), and CellMLToNektar.pycml.mathml_piecewise.get_units().

CellMLToNektar.pycml.mathml_cn.type

Definition at line 4161 of file pycml.py.