nineml.abstraction_layer.component.Alias

class nineml.abstraction_layer.component.Alias(lhs=None, rhs=None)
Aliases are a way of defining a variable local to a ComponentClass,
in terms of its Parameters, StateVariables and input Analog Ports. Alias``es allow us to reduce the duplication of code in ComponentClass definition, and allow allow more complex outputs to ``AnalogPort than simply individual StateVariables.

When specified from a string, an alias uses the notation :=

Alias``es can be defined in terms of other ``Alias``es, so for example, if we had ComponentClass representing a Hodgkin-Huxley style gating channel, which has a ``Property, reversal_potential, and an input AnalogPort, membrane_voltage, then we could define an Alias:

``driving_force := reversal_potential - membrane_voltage``

If the relevant StateVariables, m and h, for example were also defined, and a Parameter, g_bar, we could also define the current flowing through this channel as:

current := driving_force * g * m * m * m * h

This current could then be attached to an output AnalogPort for example.

It is important to ensure that Alias definitions are not circular, for example, it is not valid to define two alias in terms of each other:

a := b + 1
b := 2 * a

During code generation, we typically call ComponentClass.backsub_all(). This method first expands each alias in terms of other aliases, such that each alias depends only on Parameters, StateVariables and incoming AnalogPort. Next, it expands any alias definitions within TimeDerivatives, StateAssignments, Conditions and output AnalogPorts.

__init__(lhs=None, rhs=None)

Constructor for an Alias

Parameters:
  • lhs – A string specifying the left-hand-side, i.e. the Alias name. This should be a single symbol.
  • rhs – A string specifying the right-hand-side. This should be a mathematical expression, expressed in terms of other Aliases, StateVariables, Parameters and incoming AnalogPorts local to the Component.

Methods

__init__([lhs, rhs]) Constructor for an Alias
accept_visitor(visitor, **kwargs) link to something about visitation.
lhs_name_transform_inplace(name_map)
name_transform_inplace(name_map)
rhs_as_python_func([namespace]) Returns a python callable which evaluates the expression in
rhs_has_missing_functions() returns True if at least 1 function on the RHS is not in the math
rhs_name_transform_inplace(name_map) Replace atoms on the RHS with values in the name_map

Attributes

atoms Returns a list of the atoms in the LHS and RHS of this expression
lhs
lhs_atoms
rhs
rhs_atoms Returns an iterator over all the variable names and mathematical
rhs_funcs
rhs_missing_functions yield names of functions in the RHS which are not in the math
rhs_names
accept_visitor(visitor, **kwargs)

link to something about visitation.

lhs_name_transform_inplace(name_map)
name_transform_inplace(name_map)
rhs_as_python_func(namespace=None)

Returns a python callable which evaluates the expression in namespace and returns the result

rhs_has_missing_functions()

returns True if at least 1 function on the RHS is not in the math namespace

rhs_name_transform_inplace(name_map)

Replace atoms on the RHS with values in the name_map

atoms

Returns a list of the atoms in the LHS and RHS of this expression

lhs
lhs_atoms
rhs
rhs_atoms

Returns an iterator over all the variable names and mathematical functions on the RHS function. This does not include defined mathematical symbols such as pi and e, but does include functions such as sin and log

rhs_funcs
rhs_missing_functions

yield names of functions in the RHS which are not in the math namespace

rhs_names