Nektar++
|
Public Member Functions | |
def | __init__ (self) |
def | __del__ (self) |
def | clean_up (self) |
def | get_config (self, config_attr=None) |
def | get_option (self, option_name) |
def | get_component_by_name (self, compname) |
def | get_variable_by_name (self, compname, varname) |
def | get_variable_by_oxmeta_name (self, name, throw=True) |
def | get_variables_by_ontology_term (self, term) |
def | get_variable_by_cmeta_id (self, cmeta_id) |
def | get_all_variables (self) |
def | validation_error (self, errmsg, level=logging.ERROR) |
def | get_validation_errors (self) |
def | validation_warning (self, errmsg, level=logging.WARNING) |
def | get_validation_warnings (self) |
def | validate (self, xml_context=False, invalid_if_warnings=False, warn_on_units_errors=False, check_for_units_conversions=False, assume_valid=False, **ignored_kwargs) |
def | search_for_assignments (self, comp=None) |
def | build_name_dictionaries (self, rebuild=False) |
def | build_component_hierarchy (self, relationship, namespace=None, name=None, rels=None) |
def | topological_sort (self, node) |
def | get_assignments (self) |
def | clear_assignments (self) |
def | do_binding_time_analysis (self) |
def | get_standard_units (self) |
def | get_all_units (self) |
def | get_units_by_name (self, uname) |
def | add_units (self, name, units) |
def | has_units (self, units) |
def | add_units_conversions (self) |
def | find_state_vars (self) |
def | find_free_vars (self) |
def | calculate_extended_dependencies (self, nodes, prune=[], prune_deps=[], state_vars_depend_on_odes=False, state_vars_examined=set()) |
def | is_self_excitatory (self) |
def | xml (self, stream=None, writer=None, **wargs) |
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) |
Static Public Attributes | |
string | math_xpath_1 = u'cml:component/m:math' |
string | math_xpath_2 = u'cml:component/cml:reaction/cml:variable_ref/cml:role/m:math' |
string | apply_xpath_1 = u'/m:apply[m:eq]' |
string | apply_xpath_2 = u'/m:semantics/m:apply[m:eq]' |
Private Member Functions | |
def | _add_variable (self, var, varname, compname) |
def | _del_variable (self, varname, compname) |
def | _add_component (self, comp, special=False) |
def | _del_component (self, comp) |
def | _report_exception (self, e, show_xml_context) |
def | _validate_component_hierarchies (self) |
def | _check_variable_mappings (self) |
def | _validate_connection (self, conn) |
def | _check_variable_units_exist (self) |
def | _check_connection_units (self, check_for_units_conversions=False) |
def | _check_maths_name_references (self, expr, xml_context=False) |
def | _check_assigned_vars (self, assignments, xml_context=False) |
def | _check_cellml_subset (self, math_elts, root=True) |
def | _classify_variables (self, assignment_exprs, xml_context=False) |
def | _order_variables (self, assignment_exprs, xml_context=False) |
def | _add_sorted_assignment (self, a) |
def | _remove_assignment (self, a) |
def | _check_dimensional_consistency (self, assignment_exprs, xml_context=False, warn_on_units_errors=False, check_for_units_conversions=False) |
def | _check_unit_cycles (self, unit) |
def | _build_units_dictionary (self) |
def | _add_units_obj (self, units) |
def | _get_units_obj (self, units) |
def | _is_new_units_obj (self, units) |
Additional Inherited Members | |
Public Attributes inherited from CellMLToNektar.pycml.element_base | |
xml_attributes | |
Specialised class for the model element of a CellML document. Adds methods for collecting and reporting validation errors, etc.
def CellMLToNektar.pycml.cellml_model.__init__ | ( | self | ) |
Reimplemented from CellMLToNektar.pycml.element_base.
Definition at line 383 of file pycml.py.
def CellMLToNektar.pycml.cellml_model.__del__ | ( | self | ) |
Definition at line 395 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.clean_up().
|
private |
Add a new component to the model.
Definition at line 499 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_components.
|
private |
During the topological sort, add a finished assignment to the list. This list can then be executed in order to simulate the model. The element added can either be a MathML expression representing an assignment, or a CellML variable element, indicating an assignment due to a variable mapping.
Definition at line 1095 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_assignments.
Referenced by CellMLToNektar.pycml.cellml_model.topological_sort().
|
private |
Add a units object into the global hashmap.
Definition at line 1331 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_units_map.
Referenced by CellMLToNektar.pycml.cellml_model._build_units_dictionary(), and CellMLToNektar.pycml.cellml_model.add_units().
|
private |
Add a new variable to the model.
Definition at line 490 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_variables.
|
private |
Create a dictionary mapping units names to objects, for all units definitions in this element.
Definition at line 1210 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._add_units_obj(), CellMLToNektar.pycml.cellml_model._cml_standard_units, CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, CellMLToNektar.pycml.mathml_piecewise._cml_units, and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model.add_units(), CellMLToNektar.pycml.cellml_component.add_units(), CellMLToNektar.pycml.cellml_model.get_all_units(), CellMLToNektar.pycml.cellml_component.get_all_units(), CellMLToNektar.pycml.cellml_model.get_standard_units(), CellMLToNektar.pycml.cellml_model.get_units_by_name(), and CellMLToNektar.pycml.cellml_component.get_units_by_name().
|
private |
Check Rule 4.4.4: mathematical expressions may only modify variables belonging to the current component.
Definition at line 842 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._report_exception(), and CellMLToNektar.utilities.DEBUG().
Referenced by CellMLToNektar.pycml.cellml_model.validate().
|
private |
Warn if MathML outside the CellML subset is used.
Definition at line 853 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._check_cellml_subset(), CellMLToNektar.utilities.DEBUG(), and CellMLToNektar.pycml.cellml_model.validation_warning().
Referenced by CellMLToNektar.pycml.cellml_model._check_cellml_subset(), and CellMLToNektar.pycml.cellml_model.validate().
|
private |
Check that the units of mapped variables are dimensionally consistent. If check_for_units_conversions is True we also warn if they are not equivalent, since much processing software may not be able to handle that case.
Definition at line 786 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.get_component_by_name(), CellMLToNektar.pycml.cellml_model.get_variable_by_name(), CellMLToNektar.pycml.cellml_component.get_variable_by_name(), CellMLToNektar.pycml.cellml_model.validation_error(), and CellMLToNektar.pycml.cellml_model.validation_warning().
Referenced by CellMLToNektar.pycml.cellml_model.validate().
|
private |
Appendix C.3.6: Equation dimension checking.
Definition at line 1151 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.validate().
|
private |
Check rules 4.4.2.1 and 4.4.3.2: name references in mathematics.
Definition at line 812 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._check_maths_name_references(), and CellMLToNektar.pycml.cellml_model._report_exception().
Referenced by CellMLToNektar.pycml.cellml_model._check_maths_name_references(), and CellMLToNektar.pycml.cellml_model.validate().
|
private |
Check for cyclic units definitions. We do this by doing a depth-first search from unit.
Definition at line 1181 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._check_unit_cycles(), and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model._check_unit_cycles(), and CellMLToNektar.pycml.cellml_model.validate().
|
private |
Check Rules 3.4.{5,6}: check variable mappings and interfaces are sane.
Definition at line 663 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._validate_connection(), CellMLToNektar.pycml.cellml_model.build_name_dictionaries(), CellMLToNektar.utilities.DEBUG(), and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model._classify_variables(), and CellMLToNektar.pycml.cellml_model.validate().
|
private |
Check rule 3.4.3.3: that the units declared for variables exist.
Definition at line 774 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.get_all_variables(), and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model.validate().
|
private |
Determine the type of each variable. Note that mapped vars must have already been classified by self._check_variable_mappings, and the RELAX NG schema ensures that a variable cannot be both Mapped and MaybeConstant. Builds the equation dependency graph in the process.
Definition at line 866 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._check_variable_mappings(), CellMLToNektar.pycml.cellml_model._report_exception(), CellMLToNektar.utilities.DEBUG(), and CellMLToNektar.pycml.cellml_model.get_all_variables().
Referenced by CellMLToNektar.pycml.cellml_model.validate().
|
private |
Remove the given component from the model.
Definition at line 507 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_components.
|
private |
Remove a variable from the model.
Definition at line 495 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_variables.
|
private |
Unique-ify this units object. If an object with the same definition already exists, return that. Otherwise return the given units object. 'Same definition' is based on the cellml_units.uniquify_tuple property, which in turn is based partly on the generated name which would be given to these units, since that really *must* be unique in generated models.
Definition at line 1337 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_units_map.
|
private |
Have these units been generated already? i.e. is a units object with this definition in our map?
Definition at line 1350 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_units_map.
|
private |
Topologically sort the equation dependency graph. This orders all the assignment expressions in the model, to allow procedural code generation. It also checks that equations are not cyclic (we don't support DAEs).
Definition at line 893 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.clear_assignments().
Referenced by CellMLToNektar.pycml.cellml_model.validate().
|
private |
Remove the given assignment from our list. This method is used by the partial evaluator.
Definition at line 1106 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_assignments.
|
private |
Report an exception e as a validation error or warning. If show_xml_context is True, display the XML of the context of the exception as well.
Definition at line 533 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.validation_error(), and CellMLToNektar.pycml.cellml_model.validation_warning().
Referenced by CellMLToNektar.pycml.cellml_model._check_assigned_vars(), CellMLToNektar.pycml.cellml_model._check_maths_name_references(), and CellMLToNektar.pycml.cellml_model._classify_variables().
|
private |
Check Rule 6.4.3.2 (4): hierarchies must not be circular. Builds all the hierarchies, and checks for cycles. In the process, we also check the other rules in 6.4.3, and 6.4.2.5.
Definition at line 632 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.build_component_hierarchy(), CellMLToNektar.utilities.DEBUG(), and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model.validate().
|
private |
Validate the given connection element. Check that the given connection object defines valid mappings between variables, according to rules 3.4.5 and 3.4.6.
Definition at line 689 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.get_component_by_name(), CellMLToNektar.pycml.cellml_model.get_variable_by_name(), CellMLToNektar.pycml.cellml_component.get_variable_by_name(), and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model._check_variable_mappings().
def CellMLToNektar.pycml.cellml_model.add_units | ( | self, | |
name, | |||
units | |||
) |
Add an entry in our units dictionary for units named `name' with element object `units'.
Definition at line 1318 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._add_units_obj(), CellMLToNektar.pycml.cellml_model._build_units_dictionary(), CellMLToNektar.pycml.cellml_component._build_units_dictionary(), CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, and CellMLToNektar.pycml.mathml_piecewise._cml_units.
Referenced by CellMLToNektar.processors.ModelModifier.add_units(), CellMLToNektar.processors.ModelModifier.add_variable(), and CellMLToNektar.processors.UnitsConverter.convert_constant().
def CellMLToNektar.pycml.cellml_model.add_units_conversions | ( | self | ) |
Add explicit units conversion mathematics where necessary.
Definition at line 1357 of file pycml.py.
References CellMLToNektar.pycml.import_processors().
def CellMLToNektar.pycml.cellml_model.build_component_hierarchy | ( | self, | |
relationship, | |||
namespace = None , |
|||
name = None , |
|||
rels = None |
|||
) |
Create all the parent-child links for the given component hierarchy. relationship gives the type of the hierarchy. If it is not one of the CellML types (i.e. encapsulation or containment) then the namespace URI must be specified. Multiple non-encapsulation hierarchies of the same type can be specified by giving the name argument.
Definition at line 958 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_validation_errors, CellMLToNektar.pycml.cellml_model.build_name_dictionaries(), CellMLToNektar.pycml.cellml_model.get_component_by_name(), and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model._validate_component_hierarchies().
def CellMLToNektar.pycml.cellml_model.build_name_dictionaries | ( | self, | |
rebuild = False |
|||
) |
Create dictionaries mapping names of variables and components to the objects representing them. Dictionary keys for variables will be (component_name, variable_name). If rebuild is True, clear the dictionaries first.
Definition at line 932 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_components, CellMLToNektar.pycml.cellml_model._cml_variables, and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model._check_variable_mappings(), and CellMLToNektar.pycml.cellml_model.build_component_hierarchy().
def CellMLToNektar.pycml.cellml_model.calculate_extended_dependencies | ( | self, | |
nodes, | |||
prune = [] , |
|||
prune_deps = [] , |
|||
state_vars_depend_on_odes = False , |
|||
state_vars_examined = set() |
|||
) |
Calculate the extended dependencies of the given nodes. Recurse into the dependency graph, in order to construct a set, for each node in nodes, of all the nodes on which it depends, either directly or indirectly. Each node IS included in its own dependency set. If prune is specified, it should be a set of nodes for which we won't include their dependencies or the nodes themselves. This is useful e.g. for pruning variables required for calculating a stimulus if the stimulus is being provided by another method. prune_deps is similar: dependencies of these nodes will be excluded, but the nodes themselves will be included if asked for. If state_vars_depend_on_odes is True, then considers state variables to depend on the ODE defining them. Requires the dependency graph to be acyclic. Return the union of all the dependency sets.
Definition at line 1378 of file pycml.py.
References CellMLToNektar.translators.CellMLTranslator.calculate_extended_dependencies(), and CellMLToNektar.pycml.cellml_model.calculate_extended_dependencies().
Referenced by CellMLToNektar.pycml.cellml_model.calculate_extended_dependencies(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations_grl(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), and CellMLToNektar.translators.CellMLTranslator.output_table_index_generation().
def CellMLToNektar.pycml.cellml_model.clean_up | ( | self | ) |
Try to get the RDF library to clean up nicely.
Definition at line 398 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.__del__().
def CellMLToNektar.pycml.cellml_model.clear_assignments | ( | self | ) |
Clear the assignments list.
Definition at line 1120 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_assignments.
Referenced by CellMLToNektar.pycml.cellml_model._order_variables().
def CellMLToNektar.pycml.cellml_model.do_binding_time_analysis | ( | self | ) |
Perform a binding time analysis on the model's mathematics. This requires variables to have been classified and a topological sort of the mathematics to have been performed. Variables and top-level expressions are processed in the order given by the topological sort, hence only a single pass is necessary. Variables are classified based on their type: State, Free -> dynamic Constant -> static Mapped -> binding time of source variable Computed -> binding time of defining expression Expressions are dealt with by recursively annotating subexpressions. See code in the MathML classes for details.
Definition at line 1124 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.get_assignments().
def CellMLToNektar.pycml.cellml_model.find_free_vars | ( | self | ) |
Return a list of the free variable elements in this model.
Definition at line 1370 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.get_all_variables().
def CellMLToNektar.pycml.cellml_model.find_state_vars | ( | self | ) |
Return a list of the state variable elements in this model.
Definition at line 1362 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.get_all_variables().
def CellMLToNektar.pycml.cellml_model.get_all_units | ( | self | ) |
Get a list of all units objects, including the standard units.
Definition at line 1300 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._build_units_dictionary(), CellMLToNektar.pycml.cellml_component._build_units_dictionary(), CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, and CellMLToNektar.pycml.mathml_piecewise._cml_units.
Referenced by CellMLToNektar.pycml.cellml_model.validate().
def CellMLToNektar.pycml.cellml_model.get_all_variables | ( | self | ) |
Return an iterator over the variables in the model.
Definition at line 484 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model._check_variable_units_exist(), CellMLToNektar.pycml.cellml_model._classify_variables(), CellMLToNektar.pycml.cellml_model.find_free_vars(), and CellMLToNektar.pycml.cellml_model.find_state_vars().
def CellMLToNektar.pycml.cellml_model.get_assignments | ( | self | ) |
Return a sorted list of all the assignments in the model. Assignments can either be instances of cellml_variable, in which case they represent a variable mapping, or instances of mathml_apply, representing top-level assignment expressions.
Definition at line 1111 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_assignments.
Referenced by CellMLToNektar.pycml.cellml_model.do_binding_time_analysis().
def CellMLToNektar.pycml.cellml_model.get_component_by_name | ( | self, | |
compname | |||
) |
Return the component object that has name `compname'.
Definition at line 414 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_components.
Referenced by CellMLToNektar.pycml.cellml_model._check_connection_units(), CellMLToNektar.pycml.cellml_model._validate_connection(), and CellMLToNektar.pycml.cellml_model.build_component_hierarchy().
def CellMLToNektar.pycml.cellml_model.get_config | ( | self, | |
config_attr = None |
|||
) |
Get the configuration store if it exists, or an attribute thereof.
Definition at line 402 of file pycml.py.
def CellMLToNektar.pycml.cellml_model.get_option | ( | self, | |
option_name | |||
) |
def CellMLToNektar.pycml.cellml_model.get_standard_units | ( | self | ) |
Get a dictionary mapping the names of the standard CellML units to their definitions.
Definition at line 1294 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._build_units_dictionary(), CellMLToNektar.pycml.cellml_component._build_units_dictionary(), and CellMLToNektar.pycml.cellml_model._cml_standard_units.
def CellMLToNektar.pycml.cellml_model.get_units_by_name | ( | self, | |
uname | |||
) |
Return an object representing the element that defines the units named `uname'.
Definition at line 1309 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._build_units_dictionary(), CellMLToNektar.pycml.cellml_component._build_units_dictionary(), CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, and CellMLToNektar.pycml.mathml_piecewise._cml_units.
def CellMLToNektar.pycml.cellml_model.get_validation_errors | ( | self | ) |
Return the list of all errors found (so far) while validating this model.
Definition at line 519 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_validation_errors.
def CellMLToNektar.pycml.cellml_model.get_validation_warnings | ( | self | ) |
Return the list of all warnings found (so far) while validating this model.
Definition at line 529 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_validation_warnings.
def CellMLToNektar.pycml.cellml_model.get_variable_by_cmeta_id | ( | self, | |
cmeta_id | |||
) |
Get the unique variable in this model with the given cmeta:id attribute value.
Definition at line 474 of file pycml.py.
def CellMLToNektar.pycml.cellml_model.get_variable_by_name | ( | self, | |
compname, | |||
varname | |||
) |
Return the variable object with name `varname' in component `compname'.
Definition at line 418 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_variables, CellMLToNektar.pycml.cellml_variable.component, and CellMLToNektar.pycml.mathml.component.
Referenced by CellMLToNektar.pycml.cellml_model._check_connection_units(), and CellMLToNektar.pycml.cellml_model._validate_connection().
def CellMLToNektar.pycml.cellml_model.get_variable_by_oxmeta_name | ( | self, | |
name, | |||
throw = True |
|||
) |
Get the unique variable in this model with the given Oxford metadata name annotation. If throw is True, will raise ValueError if there is no such variable, or more than 1 match. If throw is False, returns None in these cases.
Definition at line 439 of file pycml.py.
def CellMLToNektar.pycml.cellml_model.get_variables_by_ontology_term | ( | self, | |
term | |||
) |
Return a list of variables annotated with the given ontology term. The annotations have the same form as for oxmeta name annotations (see get_variable_by_oxmeta_name). However, here we are not restricted to namespace, and no check is done on the number of results returned. The given term must be a (prefixed_name, nsuri) tuple.
Definition at line 459 of file pycml.py.
def CellMLToNektar.pycml.cellml_model.has_units | ( | self, | |
units | |||
) |
Test whether a given units definition appears in the model.
Definition at line 1327 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, and CellMLToNektar.pycml.mathml_piecewise._cml_units.
def CellMLToNektar.pycml.cellml_model.is_self_excitatory | ( | self | ) |
Determine whether this model is self-excitatory, i.e. does not require an external stimulus.
Definition at line 1446 of file pycml.py.
References CellMLToNektar.pycml.element_base.cmeta_id().
def CellMLToNektar.pycml.cellml_model.search_for_assignments | ( | self, | |
comp = None |
|||
) |
Search for assignment expressions in the model's mathematics. If comp is supplied, will only return assignments in that component.
Definition at line 918 of file pycml.py.
References CellMLToNektar.pycml.cellml_model.apply_xpath_1, CellMLToNektar.pycml.cellml_model.apply_xpath_2, CellMLToNektar.pycml.cellml_model.math_xpath_1, and CellMLToNektar.pycml.cellml_model.math_xpath_2.
Referenced by CellMLToNektar.pycml.cellml_model.validate().
def CellMLToNektar.pycml.cellml_model.topological_sort | ( | self, | |
node | |||
) |
Do a topological sort of all assignment expressions and variables in the model. node should be an expression or variable object that inherits from Colourable and has methods get_dependencies, get_component
Definition at line 1042 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._add_sorted_assignment(), CellMLToNektar.pycml.cellml_model._cml_sorting_variables_stack, CellMLToNektar.pycml.cellml_model.topological_sort(), and CellMLToNektar.pycml.cellml_model.validation_error().
Referenced by CellMLToNektar.pycml.cellml_model.topological_sort().
def CellMLToNektar.pycml.cellml_model.validate | ( | self, | |
xml_context = False , |
|||
invalid_if_warnings = False , |
|||
warn_on_units_errors = False , |
|||
check_for_units_conversions = False , |
|||
assume_valid = False , |
|||
** | ignored_kwargs | ||
) |
Validate this model. Assumes that RELAX NG validation has been done. Checks rules 3.4.2.2, 3.4.3.2, 3.4.3.3, 3.4.5.2, 3.4.5.3, 3.4.5.4, 3.4.6.2, 3.4.6.3, 3.4.6.4, 4.4.2.1, 4.4.3.2, 4.4.4, 5.4.1.2, 5.4.2.2, 6.4.2.5, 6.4.3.2, and 6.4.3.3 in the CellML 1.0 spec, and performs units checking. Note that if some checks fail, most of the remaining checks will not be performed. Hence when testing a model validate repeatedly until it passes. If xml_context is True, then the failing MathML tree will be displayed with every units error. If check_for_units_conversions is True, then generate a warning if units conversions will be needed. If assume_valid is True then fewer checks will be done - only what is required to set up the data structures needed for model transformation. Returns True iff the model validates. When invalid_if_warnings is True the model will fail to validate if there are any warnings, as well as if there are any errors.
Definition at line 545 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._check_assigned_vars(), CellMLToNektar.pycml.cellml_model._check_cellml_subset(), CellMLToNektar.pycml.cellml_model._check_connection_units(), CellMLToNektar.pycml.cellml_model._check_dimensional_consistency(), CellMLToNektar.pycml.cellml_model._check_maths_name_references(), CellMLToNektar.pycml.cellml_model._check_unit_cycles(), CellMLToNektar.pycml.cellml_model._check_variable_mappings(), CellMLToNektar.pycml.cellml_model._check_variable_units_exist(), CellMLToNektar.pycml.cellml_model._classify_variables(), CellMLToNektar.pycml.cellml_model._cml_validation_errors, CellMLToNektar.pycml.cellml_model._cml_validation_warnings, CellMLToNektar.pycml.cellml_model._order_variables(), CellMLToNektar.pycml.cellml_model._validate_component_hierarchies(), CellMLToNektar.utilities.DEBUG(), CellMLToNektar.pycml.cellml_model.get_all_units(), CellMLToNektar.pycml.cellml_component.get_all_units(), CellMLToNektar.pycml.cellml_model.math_xpath_1, CellMLToNektar.pycml.cellml_model.math_xpath_2, CellMLToNektar.pycml.element_base.rootNode(), CellMLToNektar.pycml.cellml_model.search_for_assignments(), and CellMLToNektar.pycml.cellml_model.validation_warning().
def CellMLToNektar.pycml.cellml_model.validation_error | ( | self, | |
errmsg, | |||
level = logging.ERROR |
|||
) |
Log a validation error message. Message should be a unicode string.
Definition at line 512 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_validation_errors, and tinysimd.log().
Referenced by CellMLToNektar.pycml.cellml_model._build_units_dictionary(), CellMLToNektar.pycml.cellml_component._build_units_dictionary(), CellMLToNektar.pycml.cellml_model._check_connection_units(), CellMLToNektar.pycml.cellml_model._check_unit_cycles(), CellMLToNektar.pycml.cellml_model._check_variable_mappings(), CellMLToNektar.pycml.cellml_model._check_variable_units_exist(), CellMLToNektar.pycml.cellml_model._report_exception(), CellMLToNektar.pycml.cellml_model._validate_component_hierarchies(), CellMLToNektar.pycml.cellml_model._validate_connection(), CellMLToNektar.pycml.cellml_model.build_component_hierarchy(), CellMLToNektar.pycml.cellml_model.build_name_dictionaries(), and CellMLToNektar.pycml.cellml_model.topological_sort().
def CellMLToNektar.pycml.cellml_model.validation_warning | ( | self, | |
errmsg, | |||
level = logging.WARNING |
|||
) |
Log a validation warning message. Message should be a unicode string.
Definition at line 522 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_validation_warnings, and tinysimd.log().
Referenced by CellMLToNektar.pycml.cellml_model._check_cellml_subset(), CellMLToNektar.pycml.cellml_model._check_connection_units(), CellMLToNektar.pycml.cellml_model._report_exception(), and CellMLToNektar.pycml.cellml_model.validate().
def CellMLToNektar.pycml.cellml_model.xml | ( | self, | |
stream = None , |
|||
writer = None , |
|||
** | wargs | ||
) |
Serialize back to XML. If stream is given, output to stream. If writer is given, use it directly. If neither a stream nor a writer is given, return the output text as a Python string (not Unicode) encoded as UTF-8. This overrides Amara's method, in order to force declaration of various namespaces with prefixes on this element, and to ensure the RDF annotations are up-to-date. See base class docs for possible keyword arguments.
Definition at line 1457 of file pycml.py.
References CellMLToNektar.pycml.element_base.xml_attributes.
|
private |
|
private |
|
private |
|
private |
Definition at line 902 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.topological_sort().
|
private |
Definition at line 390 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model._build_units_dictionary(), and CellMLToNektar.pycml.cellml_model.get_standard_units().
|
private |
Definition at line 389 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model._build_units_dictionary(), CellMLToNektar.pycml.cellml_component._build_units_dictionary(), CellMLToNektar.pycml.mathml_apply._set_in_units(), CellMLToNektar.pycml.mathml_piecewise._set_in_units(), CellMLToNektar.pycml.cellml_model.add_units(), CellMLToNektar.pycml.cellml_component.add_units(), CellMLToNektar.pycml.cellml_model.get_all_units(), CellMLToNektar.pycml.cellml_component.get_all_units(), CellMLToNektar.pycml.mathml_apply.get_units(), CellMLToNektar.pycml.mathml_piecewise.get_units(), CellMLToNektar.pycml.mathml_cn.get_units(), CellMLToNektar.pycml.mathml_ci.get_units(), CellMLToNektar.pycml.cellml_model.get_units_by_name(), CellMLToNektar.pycml.cellml_component.get_units_by_name(), and CellMLToNektar.pycml.cellml_model.has_units().
|
private |
Definition at line 391 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model._add_units_obj(), CellMLToNektar.pycml.cellml_model._get_units_obj(), and CellMLToNektar.pycml.cellml_model._is_new_units_obj().
|
private |
|
private |
Definition at line 386 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.get_validation_warnings(), CellMLToNektar.pycml.cellml_model.validate(), and CellMLToNektar.pycml.cellml_model.validation_warning().
|
private |
|
static |
Definition at line 915 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.search_for_assignments().
|
static |
Definition at line 916 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.search_for_assignments().
|
static |
Definition at line 913 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.search_for_assignments(), and CellMLToNektar.pycml.cellml_model.validate().
|
static |
Definition at line 914 of file pycml.py.
Referenced by CellMLToNektar.pycml.cellml_model.search_for_assignments(), and CellMLToNektar.pycml.cellml_model.validate().