pynestml.utils package
Submodules
pynestml.utils.ast_mechanism_information_collector module
- class pynestml.utils.ast_mechanism_information_collector.ASTContinuousInputDeclarationVisitor
Bases:
ASTVisitor- endvisit_input_port(node)
Used to endvisit a single input port. :param node: a single input port. :type node: ASTInputPort
- visit_input_port(node)
Used to visit a single input port. :param node: a single input port. :type node: ASTInputPort
- class pynestml.utils.ast_mechanism_information_collector.ASTFunctionCallCollectorVisitor
Bases:
ASTVisitor- endvisit_function_call(node)
Private method: Used to endvisit a single function call and update its corresponding scope. :param node: a function call object. :type node: ASTFunctionCall
- visit_function_call(node)
Private method: Used to visit a single function call and update its corresponding scope. :param node: a function call object. :type node: ASTFunctionCall
- class pynestml.utils.ast_mechanism_information_collector.ASTFunctionCollectorVisitor
Bases:
ASTVisitor- endvisit_function(node)
Used to endvisit a single function block. :param node: a function block object. :type node: ASTFunction
- visit_function(node)
Used to visit a single function block. :param node: a function block object. :type node: ASTFunction
- class pynestml.utils.ast_mechanism_information_collector.ASTInlineEquationCollectorVisitor
Bases:
ASTVisitor- endvisit_inline_expression(node)
Used to endvisit a single inline expression. :param node: a single inline expression :type node: ASTInlineExpression
- visit_inline_expression(node)
Used to visit a single inline expression. :param node: a single inline expression. :type node: ASTInlineExpression
- class pynestml.utils.ast_mechanism_information_collector.ASTKernelCollectorVisitor
Bases:
ASTVisitor- endvisit_kernel(node)
Used to endvisit a single kernel. :param node: a single kernel. :type node: ASTKernel
- visit_kernel(node)
Used to visit a single kernel. :param node: a single kernel. :type node: ASTKernel
- class pynestml.utils.ast_mechanism_information_collector.ASTMechanismInformationCollector(neuron)
Bases:
objectThis class contains all basic mechanism information collection. Further collectors may be implemented to collect further information for specific mechanism types (example: ASTSynapseInformationCollector)
Collects all parts of the nestml code the root expressions previously collected depend on. search is cut at other mechanisms root expressions
- collector_visitor = None
- classmethod detect_mechs(mech_type: str)
Detects the root expressions (either ode or inline) of the given type and returns the initial info dictionary
- classmethod extend_function_call_list_name_based_restricted(extended_list, appending_list, restrictor_list)
go through appending_list and append every variable that is not in restrictor_list to extended_list for the purpose of not re-searching the same function
- classmethod extend_variable_list_name_based_restricted(extended_list, appending_list, restrictor_list)
go through appending_list and append every variable that is not in restrictor_list to extended_list for the purpose of not re-searching the same variable
- classmethod extend_variables_with_initialisations(neuron, mechs_info)
collects initialization expressions for all variables and parameters contained in mechs_info
- neuron = None
- class pynestml.utils.ast_mechanism_information_collector.ASTMechanismInformationCollectorVisitor
Bases:
ASTVisitor- endvisit_equations_block(node)
Used to endvisit a single equations block. :param node: a single equations block. :type node: ASTEquationsBlock
- visit_equations_block(node)
Used to visit a single equations block. :param node: a single equations block. :type node: ASTEquationsBlock
- visit_inline_expression(node)
Used to visit a single inline expression. :param node: a single inline expression. :type node: ASTInlineExpression
- visit_ode_equation(node)
Used to visit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation
- class pynestml.utils.ast_mechanism_information_collector.ASTODEEquationCollectorVisitor
Bases:
ASTVisitor- endvisit_ode_equation(node)
Used to endvisit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation
- visit_ode_equation(node)
Used to visit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation
- class pynestml.utils.ast_mechanism_information_collector.ASTVariableCollectorVisitor
Bases:
ASTVisitor- endvisit_block_with_variables(node)
Used to endvisit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- endvisit_variable(node)
Used to endvisit a single variable. :param node: a single variable. :type node: ASTVariable
- visit_block_with_variables(node)
Used to visit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- visit_variable(node)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
- class pynestml.utils.ast_mechanism_information_collector.VariableInitializationVisitor(channel_info)
Bases:
ASTVisitor- endvisit_block_with_variables(node)
Used to endvisit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- endvisit_declaration(node)
Used to endvisit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- endvisit_variable(node)
Used to endvisit a single variable. :param node: a single variable. :type node: ASTVariable
- visit_block_with_variables(node)
Used to visit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- visit_declaration(node)
Used to visit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- visit_variable(node)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
pynestml.utils.ast_source_location module
- class pynestml.utils.ast_source_location.ASTSourceLocation(start_line, start_column, end_line, end_column)
Bases:
objectThis class is used to store information regarding the source position of an element. .. attribute:: start_line = 0
- start_column = 0
- end_line = 0
- end_column = 0
- before(source_position)
Checks if the handed over position is smaller than this. :param source_position: a source position. :type source_position: ASTSourceLocation :return: True if smaller, otherwise False :rtype: bool
- encloses(source_position)
- Checks if the handed over position is enclosed in this source position, e.g.,
line 0 to 10 encloses lines 0 to 9 etc.
- Parameters:
source_position (ASTSourceLocation) – a source position
- Returns:
True if enclosed, otherwise False.
- Return type:
- equals(source_position) bool
Checks if the handed over position is equal to this. :param source_position: a source position. :type source_position: ASTSourceLocation :return: True if equal, otherwise False.
- classmethod get_added_source_position()
Returns a source position which symbolize that the corresponding element has been added by the solver. :return: a source position. :rtype: ASTSourceLocation
- get_end_column()
Returns the end column of the element. :return: the end column as int :rtype: int
- get_end_line()
Returns the end line of the element. :return: the end line as int :rtype: int
- classmethod get_predefined_source_position()
Returns a source position which symbolizes that the corresponding element is predefined. :return: a source position :rtype: ASTSourceLocation
- get_start_column()
Returns the start column of the element. :return: the start column as int :rtype: int
- get_start_line()
Returns the start line of the element. :return: the start line as int :rtype: int
- is_added_source_position()
Indicates whether this represents an artificially added source position.. :return: a source position. :rtype: ASTSourceLocation
- is_predefined_source_position()
Indicates whether this represents a predefined source position. :return: True if predefined, otherwise False. :rtype: bool
- classmethod make_ast_source_position(start_line, start_column, end_line, end_column)
Factory method of the ASTSourceLocation class. :param start_line: The start line of the object :type start_line: int :param start_column: The start column of the object :type start_column: int :param end_line: The end line of the object :type end_line: int :param end_column: The end column of the object :type end_column: int :return: a new ASTSourceLocation object :rtype: ASTSourceLocation
pynestml.utils.ast_synapse_information_collector module
- class pynestml.utils.ast_synapse_information_collector.ASTSynapseInformationCollector
Bases:
ASTVisitorfor each inline expression inside the equations block, collect all synapse relevant information
- static construct_kernel_X_spike_buf_name(kernel_var_name: str, spike_input_port, order: int, diff_order_symbol='__d')
- endvisit_block_with_variables(node)
Used to endvisit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- endvisit_declaration(node)
Used to endvisit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- endvisit_equations_block(node)
Used to endvisit a single equations block. :param node: a single equations block. :type node: ASTEquationsBlock
- endvisit_expression(node)
Used to endvisit a single rhs. :param node: an rhs. :type node: ASTExpression
- endvisit_function_call(node)
Private method: Used to endvisit a single function call and update its corresponding scope. :param node: a function call object. :type node: ASTFunctionCall
- endvisit_inline_expression(node)
Used to endvisit a single inline expression. :param node: a single inline expression :type node: ASTInlineExpression
- endvisit_input_block(node)
Used to endvisit a single input block. :param node: a single input block. :type node: ASTInputBlock
- endvisit_kernel(node)
Used to endvisit a single kernel. :param node: a single kernel. :type node: ASTKernel
- endvisit_simple_expression(node)
Used to endvisit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
- get_basic_kernel_variable_names(synapse_inline)
for every occurence of convolve(port, spikes) generate “port__X__spikes” variable gather those variables for this synapse inline and return their list
note that those variables will occur as substring in other kernel variables i.e “port__X__spikes__d” or “__P__port__X__spikes__port__X__spikes”
so we can use the result to identify all the other kernel variables related to the specific synapse inline declaration
- get_extracted_kernel_args(inline_expression: ASTInlineExpression) set
- get_inline_expressions_with_kernels()
- get_inline_function_calls(inline: ASTInlineExpression)
- get_input_port_by_name(name)
- get_state_declaration(variable_name)
- get_synapse_specific_internal_declarations(synapse_inline: ASTInlineExpression) defaultdict
- get_synapse_specific_parameter_declarations(synapse_inline: ASTInlineExpression) defaultdict
- get_synapse_specific_state_declarations(synapse_inline: ASTInlineExpression) defaultdict
- get_used_kernel_names(inline_expression: ASTInlineExpression)
- get_used_spike_names(inline_expression: ASTInlineExpression)
- get_variable_declaration(variable_name)
- get_variable_names_of_synapse(synapse_inline: ASTInlineExpression, exclude_names: set = {}, exclude_ignorable=True) set
extracts all variables specific to a single synapse (which is defined by the inline expression containing kernels) independently of what block they are declared in it also cascades over all right hand side variables until all variables are included
- classmethod get_variable_names_to_ignore()
- visit_block_with_variables(node)
Used to visit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- visit_declaration(node)
Used to visit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- visit_equations_block(node)
Used to visit a single equations block. :param node: a single equations block. :type node: ASTEquationsBlock
- visit_expression(node)
Used to visit a single rhs. :param node: an rhs. :type node: ASTExpression
- visit_function_call(node)
Private method: Used to visit a single function call and update its corresponding scope. :param node: a function call object. :type node: ASTFunctionCall
- visit_inline_expression(node)
Used to visit a single inline expression. :param node: a single inline expression. :type node: ASTInlineExpression
- visit_input_block(node)
Used to visit a single input block. :param node: a single input block. :type node: ASTInputBlock
- visit_input_port(node)
Used to visit a single input port. :param node: a single input port. :type node: ASTInputPort
- visit_kernel(node)
Used to visit a single kernel. :param node: a single kernel. :type node: ASTKernel
- visit_simple_expression(node)
Used to visit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
- visit_variable(node)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
pynestml.utils.ast_utils module
- class pynestml.utils.ast_utils.ASTUtils
Bases:
objectA collection of helpful methods for AST manipulation.
- classmethod add_assignment_to_update_block(assignment: ASTAssignment, neuron: ASTModel) ASTModel
Adds a single assignment to the end of the update block of the handed over neuron. At most one update block should be present.
- Parameters:
assignment – a single assignment
neuron – a single neuron instance
- Returns:
the modified neuron
- classmethod add_declaration_to_internals(model: ASTModel, variable_name: str, init_expression: str, run_symboltable_visitor: bool = True) None
Adds the variable as stored in the declaration tuple to the model. The declared variable is of type real. :param model: a single model instance :param variable_name: the name of the variable to add :param init_expression: initialization expression
- classmethod add_declaration_to_state_block(neuron: ASTModel, variable: str, initial_value: str, type_str: str = 'real') ASTModel
Adds a single declaration to an arbitrary state block of the neuron. The declared variable is of type real. :param neuron: a neuron :param variable: state variable to add :param initial_value: corresponding initial value :return: a modified neuron
- classmethod add_declaration_to_update_block(declaration: ASTDeclaration, neuron: ASTModel) ASTModel
Adds a single declaration to the end of the update block of the handed over neuron. :param declaration: ASTDeclaration node to add :param neuron: a single neuron instance :return: a modified neuron
- classmethod add_declarations_to_internals(model: ASTModel, declarations: Mapping[str, str]) None
Adds the variables as stored in the declaration tuples to the model. :param model: a single model instance :param declarations: a map of variable names to declarations
- classmethod add_declarations_to_state_block(neuron: ASTModel, variables: List, initial_values: List) ASTModel
Adds a single declaration to the state block of the neuron. :param neuron: a neuron :param variables: list of variables :param initial_values: list of initial values :return: a modified neuron
- classmethod add_kernel_to_variable(kernel: ASTKernel)
Adds the kernel as the defining equation. If the definition of the kernel is e.g. g’’ = … then variable symbols g and g’ will have their kernel definition and variable type set. :param kernel: a single kernel object.
- classmethod add_ode_to_variable(ode_equation: ASTOdeEquation)
Resolves to the corresponding symbol and updates the corresponding ode-declaration.
- Parameters:
ode_equation – a single ode-equation
- classmethod add_state_updates(neuron: ASTModel, update_expressions: Mapping[str, str]) ASTModel
Adds all update instructions as contained in the solver output to the update block of the neuron. :param neuron: a single neuron :param update_expressions: map of variables to corresponding updates during the update step. :return: a modified version of the neuron
- classmethod add_suffix_to_decl_lhs(decl, suffix: str)
add suffix to the left-hand side of a declaration
- classmethod add_suffix_to_variable_name(var_name: str, astnode: ASTNode, suffix: str, scope=None)
add suffix to variable by given name recursively throughout astnode
- classmethod add_suffix_to_variable_names(astnode: ASTNode | List, suffix: str, altscope: Scope | None = None)
Add suffix to variable names recursively throughout
astnode. Symbols will be resolved in the variable’s default scope, unlessaltscopeis set, in which case it will be used to try to resolve variables (this can be used in case of moved variables for neuron/synapse co-generation).
- classmethod add_suffix_to_variable_names2(variable_names: List[str], astnode: ASTNode | List, suffix: str)
add suffix to variable names recursively throughout astnode
- classmethod all_variables_defined_in_block(blocks: ASTStmtsBody | List[ASTStmtsBody]) List[ASTVariable]
return a list of all variable declarations in a block or blocks
- classmethod assign_numeric_non_numeric_state_variables(model, numeric_state_variable_names, numeric_update_expressions, update_expressions, metadata)
For each ASTVariable, set the
node._is_numericmember to True or False based on whether this variable will be solved with the analytic or numeric solver.Ideally, this would not be a property of the ASTVariable as it is an implementation detail (that only emerges during code generation) and not an intrinsic part of the model itself. However, this approach is preferred over setting it as a property of the variable printers as it would have to make each printer aware of all models and variables therein.
- classmethod assign_ode_to_variables(ode_block: ASTEquationsBlock)
Adds for each variable symbol the corresponding ode declaration if present.
- Parameters:
ode_block – a single block of ode declarations.
- classmethod collect_parameters_needed_for_state_vars(model, syn_to_neuron_state_vars)
- classmethod collect_variable_names_in_expression(expr: ASTNode) List[ASTVariable]
Collect all occurrences of variables (ASTVariable) XXX … :param expr: expression to collect the variables from :return: a list of variables
- classmethod collect_variables_affected_by_ports(model, post_port_names, strictly_synaptic_vars: Set[str] | None = None)
Recursively collect a list of all variables in a model that are affected by spikes from
post_port_names. These variables are marked for moving to the postsynaptic neuron. If a variable is to strictly remain part of the synapse, it should be passed instrictly_synaptic_vars.
- classmethod collects_vars_used_in_equation(state_var, from_block)
- classmethod compute_type_name(data_type) str
Computes the representation of the data type. :param data_type: a single data type. :type data_type: ast_data_type :return: the corresponding representation.
- classmethod construct_kernel_X_spike_buf_name(kernel_var_name: str, spike_input_port: ASTInputPort, order: int, diff_order_symbol='__d', suffix='')
Construct a kernel-buffer name as <KERNEL_NAME__X__INPUT_PORT_NAME>
For example, if the kernel is .. code-block:
kernel I_kernel = exp(-t / tau_x)
and the input port is .. code-block:
pre_spikes <- spike
then the constructed variable will be “I_kernel__X__pre_pikes”
- classmethod contains_convolve_call(variable: VariableSymbol) bool
Indicates whether the declaring rhs of this variable symbol has a convolve() in it. :return: True if contained, otherwise False.
- classmethod contains_convolve_function_call(ast: ASTNode) bool
Indicates whether _ast or one of its child nodes contains a sum call. :param ast: a single meta_model :return: True if sum is contained, otherwise False.
- classmethod create_equations_block(model: ASTModel) ASTModel
Create an equations block in the handed over model if it does not yet exist. :param model: a single model :return: the modified model (the model is also changed in-place)
- classmethod create_initial_values_for_kernels(model: ASTModel, solver_dicts: List[Dict], kernels: List[ASTKernel]) None
Add the variables used in kernels from the ode-toolbox result dictionary as ODEs in NESTML AST
- classmethod create_integrate_odes_combinations(model: ASTModel) List[str]
Visit all integrate_odes() calls in the model and compose these as a list of strings.
- classmethod create_internal_block(model: ASTModel)
Create an internals block in the handed over model if it does not yet exist. :param model: a single model :return: the modified model (the model is also changed in-place)
- classmethod create_parameters_block(model: ASTModel)
Create a parameters block in the handed over model if it does not yet exist. :param model: a single model :return: the modified model (the model is also changed in-place)
- classmethod create_state_block(model: ASTModel)
Create a state block in the handed over model if it does not yet exist. :param model: a single model :return: the modified model (the model is also changed in-place)
- classmethod declaration_in_state_block(neuron: ASTModel, variable_name: str) bool
Checks if the variable is declared in the state block :param neuron: :param variable_name: :return:
- classmethod deconstruct_assignment(lhs=None, is_plus=False, is_minus=False, is_times=False, is_divide=False, _rhs=None)
From lhs and rhs it constructs a new rhs which corresponds to direct assignment. E.g.: a += b*c -> a = a + b*c :param lhs: a lhs rhs :type lhs: ast_expression or ast_simple_expression :param is_plus: is plus assignment :type is_plus: bool :param is_minus: is minus assignment :type is_minus: bool :param is_times: is times assignment :type is_times: bool :param is_divide: is divide assignment :type is_divide: bool :param _rhs: a rhs rhs :type _rhs: ASTExpression or ASTSimpleExpression :return: a new direct assignment rhs. :rtype: ASTExpression
- classmethod depends_only_on_vars(expr, vars)
Returns True if and only if all variables that occur in
exprare invars
- classmethod equations_from_block_to_block(state_var, from_block, to_block, var_name_suffix, mode) List[ASTDeclaration]
- classmethod extract_delay_parameter(node: ASTFunctionCall) str
Extracts the delay parameter from the delayed variable :param node: The delayed variable parsed as a function call
- classmethod filter_variables_list(variables_list, variables_to_filter_by)
- classmethod find_parent_node_by_type(node: ASTNode, type_to_find: Any) Any | None
Find the first parent of the given node that has the type
type_to_find. Return None if no parent with that type could be found.
- classmethod get_all(ast, node_type)
Finds all meta_model which are part of the tree as spanned by the handed over meta_model. The type has to be specified. :param ast: a single meta_model node :type ast: AST_ :param node_type: the type :type node_type: AST_ :return: a list of all meta_model of the specified type :rtype: list(AST_)
- classmethod get_all_integrate_odes_calls_unique(model: ASTModel) List[ASTFunctionCall]
Get a list of all unique
integrate_odes()function calls in the model (i.e. each having a different set of parameters).
- classmethod get_all_models(list_of_compilation_units)
For a list of compilation units, it returns a list containing all nodes defined in all compilation units. :param list_of_compilation_units: a list of compilation units. :type list_of_compilation_units: list(ASTNestMLCompilationUnit) :return: a list of nodes :rtype: list(ASTNode)
- classmethod get_all_neurons(list_of_compilation_units)
For a list of compilation units, it returns a list containing all neurons defined in all compilation units. :param list_of_compilation_units: a list of compilation units. :type list_of_compilation_units: list(ASTNestMLCompilationUnit) :return: a list of neurons :rtype: list(ASTModel)
- classmethod get_all_variables(node: ASTNode) List[str]
Make a list of all variable symbol names that are in
node
- classmethod get_all_variables_assigned_to(node: ASTNode) Set[str]
Return a list of all variables that are assigned to in
node.
- classmethod get_all_variables_in_expression(expr: ASTExpression) List[ASTVariable]
- classmethod get_all_variables_names_in_expression(expr: ASTExpression) List[str]
Get variable names of any order (foo, foo’, foo’’, etc. will result in “foo” being added to the list returned)
- classmethod get_all_variables_used_in_convolutions(nodes: ASTEquationsBlock | List[ASTEquationsBlock], parent_node: ASTNode) List[str]
Make a list of all variable symbol names that are in one of the equation blocks in
nodesand used in a convolution
- classmethod get_convolve_function_calls(nodes: ASTNode | List[ASTNode])
Returns all sum function calls in the handed over meta_model node or one of its children. :param nodes: a single or list of AST nodes.
- classmethod get_convolve_vars_exclude_port(nodes: ASTEquationsBlock | Sequence[ASTEquationsBlock], excluded_port_names: List[str], parent_node: ASTNode)
Gather all variables that are used in a convolution with an input port that is not in
excluded_port_names.
- classmethod get_declaration_by_name(blocks: ASTStmtsBody | List[ASTStmtsBody], var_name: str) ASTDeclaration | None
Get a declaration by variable name. :param blocks: the block or blocks to look for the variable in :param var_name: name of the variable to look for (including single quotes indicating differential order)
- classmethod get_declarations_from_block(var_name: str, block: ASTStmtsBody) List[ASTDeclaration]
Get declarations from the given block containing the given variable on the left-hand side.
- Parameters:
var_name – variable name
block – block to collect the variable declarations
- Returns:
a list of declarations
- classmethod get_delay_variable_symbol(node: ASTFunctionCall) VariableSymbol | None
Returns the variable symbol for the corresponding delayed variable :param node: The delayed variable parsed as a function call
- classmethod get_dependent_variables(var: str, model: ASTNode) Set[str]
Return a set of all left-hand side variables in the model that depend on
varin their right-hand side.
- classmethod get_expr_from_kernel_var(kernel: ASTKernel, var_name: str) ASTExpression | ASTSimpleExpression
Get the expression using the kernel variable
- classmethod get_first_spike_port_from_spike_updates(neuron: ASTModel) ASTVariable
- classmethod get_function_call(ast, function_name)
Collects for a given name all function calls in a given meta_model node. :param ast: a single node :type ast: ast_node :param function_name: the name of the function :type function_name: str :return: a list of all function calls contained in _ast :rtype: list(ASTFunctionCall)
- classmethod get_function_calls(ast_node: ASTNode, function_list: List[str]) List[ASTFunctionCall]
For a handed over list of function names, this method retrieves all function calls in the meta_model. :param ast_node: a single meta_model node :param function_list: a list of function names :return: a list of all functions in the meta_model
- classmethod get_higher_order_variables(var, variables_list, variables_to_filter_by) List[str]
Returns a list of higher order state variables of
varfrom thevariables_listthat are not already present invariables_to_filter_by.
- classmethod get_initial_value_from_ode_toolbox_result(var_name: str, solver_dicts: List[dict]) str
Get the initial value of the variable with the given name from the ode-toolbox results JSON.
N.B. the variable name is given in ode-toolbox notation.
- classmethod get_inline_expression_by_constructed_rhs_name(node, name: str) ASTInlineExpression | None
- classmethod get_inline_expression_by_name(node, name: str) ASTInlineExpression | None
- classmethod get_inline_expression_symbols(ast: ASTNode) List[VariableSymbol]
For the handed over AST node, this method collects all inline expression variable symbols in it. :param ast: a single AST node :return: a list of all inline expression variable symbols
- classmethod get_input_port_by_name(input_blocks: List[ASTInputBlock], port_name: str) ASTInputPort | None
Get the input port given the port name :param input_block: block to be searched :param port_name: name of the input port :return: input port object
- classmethod get_integrate_odes_parent(node: ASTFunctionCall) ASTNode
- classmethod get_internal_decl_by_name(node: ASTModel, var_name: str) ASTDeclaration
Get the declaration based on the name of the internal parameter :param node: the neuron or synapse containing the parameter :param var_name: variable name to be searched :return: declaration containing the variable
- classmethod get_internal_variable_by_name(node: ASTModel, var_name: str) ASTVariable
Get the internal parameter node based on the name of the internal parameter :param node: the neuron or synapse containing the parameter :param var_name: variable name to be searched :return: declaration containing the variable
- classmethod get_kernel_var_order_from_ode_toolbox_result(kernel_var: str, solver_dicts: List[dict]) int
Get the differential order of the variable with the given name from the ode-toolbox results JSON.
N.B. the variable name is given in NESTML notation, e.g. “g_in$”; convert to ode-toolbox export format notation (e.g. “g_in__DOLLAR”).
- classmethod get_necessary_variables(var: str, model: ASTExpression) List[ASTVariable]
Return a list of all right-hand side variables in the model that a certain, given left-hand side variable
vardepends on.
- classmethod get_numeric_vector_input_port_size(port: ASTInputPort) int
Returns the numerical size of the vector by resolving any variable used as a size parameter in declaration :param port: input port :return: the size of the vector as a numerical value
- classmethod get_numeric_vector_size(variable: VariableSymbol) int
Returns the numerical size of the vector by resolving any variable used as a size parameter in declaration :param variable: vector variable :return: the size of the vector as a numerical value
- classmethod get_on_receive_blocks_by_input_port_name(model: ASTModel, port_name: str) List[ASTOnReceiveBlock]
Get the onReceive blocks in the model associated with a given input port.
- classmethod get_parameter_by_name(node: ASTModel, var_name: str) ASTDeclaration
Get the declaration based on the name of the parameter :param node: the neuron or synapse containing the parameter :param var_name: variable name to be searched :return: declaration containing the variable
- classmethod get_parameter_variable_by_name(node: ASTModel, var_name: str) ASTVariable
Get a parameter node based on the name of the parameter :param node: the neuron or synapse containing the parameter :param var_name: variable name to be searched :return: the parameter node
- classmethod get_post_ports_of_neuron_synapse_pair(neuron, synapse, codegen_opts_pairs)
- classmethod get_state_variable_by_name(node: ASTModel, var_name: str) ASTVariable | None
Get a state variable node based on the name :param node: the neuron or synapse containing the parameter :param var_name: variable name to be searched :return: the node if found, otherwise None
- classmethod get_state_variable_declaration_by_name(node: ASTModel, var_name: str) ASTDeclaration | None
Get the declaration based on the name of the parameter :param node: the neuron or synapse containing the parameter :param var_name: variable name to be searched :return: declaration containing the variable if found, otherwise None
- classmethod get_statements_from_block(var_name, block)
XXX: only simple statements such as assignments are supported for now. if..then..else compound statements and so are not yet supported.
- classmethod get_tuple_from_single_dict_entry(dict_entry)
For a given dict of length 1, this method returns a tuple consisting of (key,value) :param dict_entry: a dict of length 1 :type dict_entry: dict :return: a single tuple :rtype: tuple
- classmethod get_unit_name(variable: ASTVariable) str
- classmethod get_variable_by_name(node: ASTModel, var_name: str) ASTVariable | None
Get a variable or parameter node based on the name :param node: the neuron or synapse containing the parameter :param var_name: variable name to be searched :return: the node if found, otherwise None
- classmethod get_vectorized_variable(ast, scope)
Returns all variable symbols which are contained in the scope and have a size parameter. :param ast: a single meta_model :type ast: AST_ :param scope: a scope object :type scope: Scope :return: the first element with the size parameter :rtype: variable_symbol
- classmethod has_continuous_input(body: ASTModelBody) bool
Checks if the handed over neuron contains a continuous time input port. :param body: a single body element. :return: True if continuous time input port is contained, otherwise False.
- classmethod has_equation_with_delay_variable(equations_with_delay_vars: ASTOdeEquation, sym: str) bool
Returns true if the given variable has an equation defined with a delayed variable, false otherwise. :param equations_with_delay_vars: a list of equations containing delayed variables :param sym: symbol denoting the lhs of
- classmethod has_spike_input(body: ASTModelBody) bool
Checks if the handed over neuron contains a spike input port. :param body: a single body element. :return: True if spike input port is contained, otherwise False.
- classmethod integrate_odes_args_str_from_function_call(function_call: ASTFunctionCall)
- classmethod integrate_odes_args_strs_from_function_call(function_call: ASTFunctionCall)
- classmethod is_castable_to(type_a, type_b)
Indicates whether typeA can be casted to type b. E.g., in Nest, a unit is always casted down to real, thus a unit where unit is expected is allowed. :param type_a: a single TypeSymbol :type type_a: type_symbol :param type_b: a single TypeSymbol :type type_b: TypeSymbol :return: True if castable, otherwise False :rtype: bool
- classmethod is_compound_stmt(ast)
Indicates whether the handed over meta_model is a compound statement. Used in the template. :param ast: a single meta_model object. :type ast: AST_ :return: True if compound stmt, otherwise False. :rtype: bool
- classmethod is_declaring_expression_parameter(expr: ASTExpression) bool
- classmethod is_declaring_expression_state_variable(expr: ASTExpression) bool
- classmethod is_delta_kernel(kernel: ASTKernel) bool
Catches definition of kernel, or reference (function call or variable name) of a delta kernel function.
- classmethod is_elif_clause(node)
- classmethod is_else_clause(node)
- classmethod is_function_delay_variable(node: ASTFunctionCall) bool
Checks if the given function call is actually a delayed variable. For a function call to be a delayed variable, the function name should be resolved to a state symbol, with one function argument which is an expression. :param node: The function call
- classmethod is_if_clause(node)
- classmethod is_ode_variable(var_base_name: str, neuron: ASTModel) bool
Checks if the variable is present in an ODE
- classmethod is_small_stmt(ast)
Indicates whether the handed over meta_model is a small statement. Used in the template. :param ast: a single meta_model object. :type ast: AST_ :return: True if small stmt, otherwise False. :rtype: bool
- classmethod move_decls(var_name, from_block, to_block, var_name_suffix: str, block_type: BlockType, mode='move') List[ASTDeclaration]
Move or copy declarations from
from_blocktoto_block.
- classmethod needs_arguments(ast_function_call)
Indicates whether a given function call has any arguments :param ast_function_call: a function call :type ast_function_call: ASTFunctionCall :return: True if arguments given, otherwise false :rtype: bool
- classmethod nestml_input_port_to_nest_rport(astnode: ASTModel, spike_in_port: ASTInputPort)
- classmethod port_name_printer(variable: ASTVariable) str
- classmethod print_alternate_var_name(var_name, continuous_post_ports)
- classmethod recursive_dependent_variables_search(vars: Iterable[str], model: ASTModel) Set[str]
Collect all the variable names used in the defining expressions of a list of variables. :param vars: list of variable names moved from synapse to neuron :param model: ASTModel to perform the recursive search :return: list of variable names from the recursive search
- classmethod recursive_necessary_variables_search(vars: List[str], model: ASTModel) List[str]
Collect all the variable names used in the defining expressions of a list of variables. :param vars: list of variable names moved from synapse to neuron :param model: ASTModel to perform the recursive search :return: list of variable names from the recursive search
- classmethod remove_initial_values_for_kernels(model: ASTModel) None
Remove initial values for original declarations (e.g. g_in, g_in’, V_m); these might conflict with the initial value expressions returned from ODE-toolbox.
- classmethod remove_kernel_definitions_from_equations_block(model: ASTModel) Set[ASTDeclaration]
Removes all kernels in equations blocks.
- classmethod remove_ode_definitions_from_equations_block(model: ASTModel) None
Removes all ODE definitions from all equations blocks in the model.
- classmethod remove_state_var_from_integrate_odes_calls(model: ASTModel, state_var_name: str)
Remove a state variable from the arguments (where it exists) of each integrate_odes() call in the model.
- classmethod replace_convolution_aliasing_inlines(neuron: ASTModel) None
Replace all occurrences of kernel names (e.g.
I_dendandI_dend'for a definition involving a second-order kernelinline kernel I_dend = convolve(kern_name, spike_buf)) with the ODE-toolbox generated variablekern_name__X__spike_buf.
- classmethod replace_post_moved_variable_names(astnode, post_connected_continuous_input_ports, post_variable_names)
In the synapse, continuous-valued input ports could be referred to based on their name. When they are moved to the neuron, they need to be referred to by the variable name as it exists on the neuron side. This function performs the variable name replacement recursively in
astnode.astnodecan also be a list of nodes.
- classmethod replace_rhs_variable(expr: ASTExpression, variable_name_to_replace: str, kernel_var: ASTVariable, spike_buf: ASTInputPort)
Replace variable names in definitions of kernel dynamics :param expr: expression in which to replace the variables :param variable_name_to_replace: variable name to replace in the expression :param kernel_var: kernel variable instance :param spike_buf: input port instance :return:
- classmethod replace_rhs_variables(expr: ASTExpression, kernel_buffers: Mapping[ASTKernel, ASTInputPort])
Replace variable names in definitions of kernel dynamics.
Say that the kernel is
G = -G / tau
Its variable symbol might be replaced by “G__X__spikesEx”:
G__X__spikesEx = -G / tau
This function updates the right-hand side of expr so that it would also read (in this example):
G__X__spikesEx = -G__X__spikesEx / tau
These equations will later on be fed to ode-toolbox, so we use the symbol “’” to indicate differential order.
Note that for kernels/systems of ODE of dimension > 1, all variable orders and all variables for this kernel will already be present in kernel_buffers.
- classmethod replace_variable_names_in_expressions(model: ASTModel, solver_dicts: List[dict]) None
Replace all occurrences of variables names in NESTML format (e.g. g_ex$’’)` with the ode-toolbox formatted variable name (e.g. g_ex__DOLLAR__d__d).
Variables aliasing convolutions should already have been covered by replace_convolution_aliasing_inlines().
- classmethod replace_with_external_variable(var_name, node: ASTNode, suffix: str, new_scope, alternate_name=None)
Replace all occurrences of variables (
ASTVariable``s) (e.g. ``post_trace') in the node with ``ASTExternalVariable``s, indicating that they are moved to the postsynaptic neuron.
- classmethod resolve_to_variable_symbol_in_blocks(variable_name: str, blocks: List[ASTStmtsBody])
Resolve a variable (by name) to its corresponding
Symbolwithin the AST blocks inblocks.
- classmethod resolve_variables_to_expressions(astnode, analytic_state_variables_moved)
receives a list of variable names (as strings) and returns a list of ASTExpressions containing each ASTVariable
- classmethod set_new_scope(astnode: ASTNode | List, new_scope: Scope)
set new scope on variables recursively throughout astnode
- classmethod to_ode_toolbox_processed_name(name: str) str
Convert name in the same way as ode-toolbox does from input to output, i.e. returned names are compatible with ode-toolbox output
- classmethod transform_ode_and_kernels_to_json(model: ASTModel, parameters_blocks: Sequence[ASTBlockWithVariables], kernel_buffers: Mapping[ASTKernel, ASTInputPort], printer: ASTPrinter) Dict
Converts AST node to a JSON representation suitable for passing to ode-toolbox.
Each kernel has to be generated for each spike buffer convolve in which it occurs, e.g. if the NESTML model code contains the statements
convolve(G, exc_spikes) convolve(G, inh_spikes)
then kernel_buffers will contain the pairs (G, exc_spikes) and (G, inh_spikes), from which two ODEs will be generated, with dynamical state (variable) names G__X__exc_spikes and G__X__inh_spikes.
- classmethod update_blocktype_for_common_parameters(node)
Change the BlockType for all homogeneous parameters to BlockType.COMMON_PARAMETER
- classmethod update_delay_parameter_in_state_vars(neuron: ASTModel, state_vars_before_update: List[VariableSymbol]) None
Updates the delay parameter in state variables after the symbol table update :param neuron: AST neuron :param state_vars_before_update: State variables before the symbol table update
- classmethod update_initial_values_for_odes(model: ASTModel, solver_dicts: List[dict]) None
Update initial values for original ODE declarations (e.g. V_m’, g_ahp’’) that are present in the model before ODE-toolbox processing, with the formatted variable names and initial values returned by ODE-toolbox.
pynestml.utils.ast_vector_parameter_setter_and_printer module
- class pynestml.utils.ast_vector_parameter_setter_and_printer.ASTVectorParameterSetterAndPrinter
Bases:
ASTPrinter- print(node)
- set_vector_parameter(node, vector_parameter=None)
pynestml.utils.ast_vector_parameter_setter_and_printer_factory module
pynestml.utils.chan_info_enricher module
- class pynestml.utils.chan_info_enricher.ChanInfoEnricher(params)
Bases:
MechsInfoEnricherClass extends MechsInfoEnricher by the computation of the inline derivative. This hasn’t been done in the channel processing because it would cause a circular dependency through the coco checks used by the ModelParser which we need to use.
- classmethod compute_expression_derivative(chan_info)
- classmethod enrich_mechanism_specific(neuron, mechs_info)
pynestml.utils.channel_processing module
- class pynestml.utils.channel_processing.ChannelProcessing(params)
Bases:
MechanismProcessingExtends MechanismProcessing. Searches for Variables that if 0 lead to the root expression always beeing zero so that the computation can be skipped during the simulation
- classmethod check_if_key_zero_var_for_expression(rhs_expression_str, var_str)
check if var being zero leads to the expression always being zero so that the computation may be skipped if this is determined to be the case during simulation.
- classmethod collect_information_for_specific_mech_types(neuron, mechs_info)
- mechType = 'channel'
- classmethod search_for_key_zero_parameters_for_expression(rhs_expression_str, parameters)
Searching for parameters in the root-expression that if zero lead to the expression always being zero so that the computation may be skipped.
- classmethod write_key_zero_parameters_for_root_inlines(chan_info)
pynestml.utils.cloning_helpers module
- pynestml.utils.cloning_helpers.clone_numeric_literal(numeric_literal)
pynestml.utils.con_in_info_enricher module
- class pynestml.utils.con_in_info_enricher.ConInInfoEnricher(params)
Bases:
MechsInfoEnricherClass extends MechsInfoEnricher by the computation of the inline derivative. This hasn’t been done in the channel processing because it would cause a circular dependency through the coco checks used by the ModelParser which we need to use.
- classmethod compute_expression_derivative(chan_info)
- classmethod enrich_mechanism_specific(neuron, mechs_info)
pynestml.utils.conc_info_enricher module
- class pynestml.utils.conc_info_enricher.ConcInfoEnricher(params)
Bases:
MechsInfoEnricherJust created for consistency with the rest of the mechanism generation process. No more than the base-class enriching needs to be done
pynestml.utils.concentration_processing module
- class pynestml.utils.concentration_processing.ConcentrationProcessing(params)
Bases:
MechanismProcessingThe default Processing ignores the root expression when solving the odes which in case of the concentration mechanism is a ode that needs to be solved. This is added here.
- classmethod check_if_key_zero_var_for_expression(rhs_expression_str, var_str)
check if var being zero leads to the expression always being zero so that the computation may be skipped if this is determined to be the case during simulation.
- classmethod collect_information_for_specific_mech_types(neuron, mechs_info)
- mechType = 'concentration'
- classmethod ode_toolbox_processing_for_root_expression(neuron, conc_info)
applies the ode_toolbox_processing to the root_expression since that was never appended to the list of ODEs in the base processing and thereby also never went through the ode_toolbox processing
- classmethod search_for_key_zero_parameters_for_expression(rhs_expression_str, parameters)
- classmethod write_key_zero_parameters_for_root_odes(conc_info)
pynestml.utils.continuous_input_processing module
- class pynestml.utils.continuous_input_processing.ContinuousInputProcessing(params)
Bases:
MechanismProcessing- classmethod collect_information_for_specific_mech_types(neuron, mechs_info)
- mechType = 'continuous_input'
pynestml.utils.error_listener module
pynestml.utils.logger module
- class pynestml.utils.logger.Logger
Bases:
objectThis class represents a logger which can be used to print messages to the screen depending on the logging level.
- LEVELS:
DEBUG Print all received messages. INFO Print all received information messages, warnings and errors. WARNING Print all received warnings and errors. ERROR Print all received errors. NO Print no messages.
Hereby, errors are the most specific level, thus no warnings and non critical messages are shown. If logging level is set to WARNING, only warnings and errors are printed. Only if level is set to DEBUG, all messages are printed.
- log Stores all messages as received during the execution. The log is a map from ID
(artifact_name, current_node, log_level, code, error_position, message).
- Type:
- curr_message A counter indicating the current message, this enables a sorting by the number of message
- logging_level Indicates messages of which level shall be printed to the screen.
- current_node The currently processed model. This enables to retrieve all messages belonging to a certain model
- curr_message = None
- current_node = None
- classmethod freeze_log(do_freeze: bool = True)
Freeze the log: while log is frozen, all logging requests will be ignored.
- classmethod get_json_format() str
Returns the log in a format which can be used to be stored to a file. :return: a string containing the log
- classmethod get_log() Mapping[int, Tuple[ASTNode, LoggingLevel, str]]
Returns the overall log of messages.
The log is a map from ID (int) to a tuple: (artifact_name, current_node, log_level, code, error_position, message).
- Returns:
the log
- classmethod get_messages(node_or_node_name: ASTNode | str | None = None, level: LoggingLevel | None = None, message_code: int | None = None, artifact_name: str | None = None) List[Tuple[ASTNode, LoggingLevel, str]]
Returns all messages which have a certain logging level, or have been reported for a certain node, or both.
- Parameters:
node – a single node instance
level – a logging level
- Returns:
a list of messages with their levels.
- classmethod has_errors(node: ASTNode) bool
Indicates whether the handed over node, thus the corresponding model, has errors.
- Parameters:
node – a single node instance.
- Returns:
True if errors detected, otherwise False
- classmethod init_logger(logging_level: LoggingLevel)
Initializes the logger.
- Parameters:
logging_level (LoggingLevel) – the logging level as required
- classmethod level_to_string(level: LoggingLevel) str
Returns a string representation of the handed over logging level. :param level: LoggingLevel to convert. :return: a string representing the logging level.
- log = {}
- log_frozen = False
- classmethod log_message(node: ASTNode | None = None, code: MessageCode | None = None, message: str | None = None, error_position: ASTSourceLocation | None = None, log_level: LoggingLevel | None = None, allow_duplicates: bool = False)
Logs the handed over message on the handed over node. If the current logging is appropriate, the message is also printed.
- Parameters:
node – the node in which the error occurred
code – a single error code
error_position – the position on which the error occurred.
message – a message.
log_level – the corresponding log level.
allow_duplicates – whether to ignore or suppress duplicate messages.
- logging_level = None
- no_print = False
- classmethod set_current_node(node: ASTNode | None) None
Sets the handed over node as the currently processed one. This enables a retrieval of messages for a specific node.
- Parameters:
node – a single node instance
- classmethod set_log(log, counter)
Restores log from the “log” variable
- Parameters:
log – the log
counter – the counter
- classmethod set_logging_level(level: LoggingLevel) None
Updates the logging level to the handed over one. :param level: a new logging level. :type level: LoggingLevel
- classmethod string_to_level(string: str) LoggingLevel
Returns the logging level corresponding to the handed over string. If no such exits, returns None.
- Parameters:
string – a single string representing the level.
- Returns:
a single logging level.
pynestml.utils.logging_helper module
expression : left=expression (plusOp=”+” | minusOp=”-”) right=expression
pynestml.utils.mechanism_processing module
- class pynestml.utils.mechanism_processing.MechanismProcessing
Bases:
objectManages the collection of basic information necesary for all types of mechanisms and uses the collect_information_for_specific_mech_types interface that needs to be implemented by the specific mechanism type processing classes
- classmethod check_co_co(neuron: ASTModel)
Checks if mechanism conditions apply for the handed over neuron. :param neuron: a single neuron instance.
- classmethod collect_information_for_specific_mech_types(neuron, mechs_info)
- classmethod collect_raw_odetoolbox_output(mechs_info)
calls ode-toolbox for each ode individually and collects the raw output
- classmethod determine_dependencies(mechs_info)
- first_time_run = {}
- classmethod get_mechs_info(neuron: ASTModel)
returns previously generated mechs_info as a deep copy so it can’t be changed externally via object references :param neuron: a single neuron instance.
- mechType = ''
- mechs_info = {}
- classmethod ode_toolbox_processing(neuron, mechs_info)
- classmethod prepare_equations_for_ode_toolbox(neuron, mechs_info)
Transforms the collected ode equations to the required input format of ode-toolbox and adds it to the mechs_info dictionary
- classmethod print_dictionary(dictionary, rec_step)
Print the mechanisms info dictionaries.
- classmethod print_element(name, element, rec_step)
pynestml.utils.mechs_info_enricher module
- class pynestml.utils.mechs_info_enricher.ASTEnricherInfoCollectorVisitor
Bases:
ASTVisitor- endvisit_block_with_variables(node)
Used to endvisit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- endvisit_declaration(node)
Used to endvisit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- endvisit_variable(node)
Used to endvisit a single variable. :param node: a single variable. :type node: ASTVariable
- visit_block_with_variables(node)
Used to visit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- visit_declaration(node)
Used to visit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- visit_variable(node)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
- class pynestml.utils.mechs_info_enricher.MechsInfoEnricher
Bases:
objectAdds information collection that can’t be done in the processing class since that is used in the cocos. Here we use the ModelParser which would lead to a cyclic dependency.
- classmethod enrich_mechanism_specific(neuron, mechs_info)
- classmethod transform_ode_solutions(neuron, mechs_info)
pynestml.utils.messages module
- class pynestml.utils.messages.MessageCode(value)
Bases:
EnumA mapping between codes and the corresponding messages.
- ADD_SUB_TYPE_MISMATCH = 7
- ANALYSING_TRANSFORMING_MODEL = 63
- ARG_NOT_SPIKE_INPUT = 20
- ASSIGNING_TO_INLINE = 92
- ASTDATATYPE_TYPE_SYMBOL_COULD_NOT_BE_DERIVED = 71
- BLOCK_NOT_CORRECT = 24
- CAST_NOT_POSSIBLE = 5
- CM_FUNCTION_BAD_NUMBER_ARGS = 103
- CM_FUNCTION_BAD_RETURN_TYPE = 104
- CM_FUNCTION_MISSING = 101
- CM_NO_GATING_VARIABLES = 100
- CM_NO_VALUE_ASSIGNMENT = 106
- CM_NO_V_COMP = 108
- CM_VARIABLES_NOT_DECLARED = 102
- CM_VARIABLE_NAME_MULTI_USE = 105
- CODE_SUCCESSFULLY_GENERATED = 13
- CONVOLVE_NEEDS_BUFFER_PARAMETER = 119
- CREATING_INSTALL_PATH = 89
- CREATING_TARGET_PATH = 90
- DELAY_VARIABLE = 84
- DELAY_VARIABLE_NOT_FOUND = 123
- DELAY_VARIABLE_NOT_SPECIFIED = 121
- DELTA_FUNCTION_CANNOT_BE_MIXED = 69
- EMIT_SPIKE_FUNCTION_BUT_NO_OUTPUT_PORT = 74
- EMIT_SPIKE_OUTPUT_PORT_TYPE_DIFFERS = 115
- EQUATIONS_DEFINED_BUT_INTEGRATE_ODES_NOT_CALLED = 77
- EXPONENT_MUST_BE_INTEGER = 114
- FUNCTION_CALL_TYPE_ERROR = 2
- FUNCTION_NOT_DECLARED = 30
- FUNCTION_REDECLARED = 29
- HARD_INCOMPATIBILITY = 45
- IMPLICIT_CAST = 4
- INPUT_PATH_NOT_FOUND = 58
- INPUT_PORT_SIZE_NOT_GREATER_THAN_ZERO = 87
- INPUT_PORT_SIZE_NOT_INTEGER = 86
- INSTALL_PATH_INFO = 88
- INTEGRATE_ODES_ARG_HIGHER_ORDER = 117
- INTEGRATE_ODES_WRONG_ARG = 91
- INTERNAL_WARNING = 55
- KERNEL_IV_WRONG_TYPE = 73
- KERNEL_OUTSIDE_CONVOLVE = 35
- KERNEL_WRONG_TYPE = 72
- LEXER_ERROR = 59
- MECHS_DICTIONARY_INFO = 109
- MODEL_CONTAINS_ERRORS = 11
- MODEL_REDECLARED = 33
- MODULE_NAME_INFO = 66
- MODULE_SUCCESSFULLY_GENERATED = 14
- MULTIPLE_KEYWORDS = 41
- NAME_COLLISION = 36
- NEST_COLLISION = 34
- NEURON_SOLVED_BY_GSL = 52
- NON_CONSTANT_EXPONENT = 111
- NOT_A_VARIABLE = 40
- NOT_LAST_STATEMENT = 47
- NO_ASSIGNMENT_ALLOWED = 39
- NO_CODE_GENERATED = 15
- NO_FILES_IN_INPUT_PATH = 75
- NO_INIT_VALUE = 32
- NO_ODE = 31
- NO_RETURN = 46
- NO_RHS = 27
- NO_TYPE_ALLOWED = 38
- NO_UNIT = 53
- NO_VARIABLE_FOUND = 9
- NUMERATOR_NOT_ONE = 21
- ODE_FUNCTION_NEEDS_CONSISTENT_UNITS = 68
- ODE_NEEDS_CONSISTENT_UNITS = 64
- OPERATION_NOT_DEFINED = 56
- ORDER_NOT_DECLARED = 22
- PARSER_ERROR = 60
- PRIORITY_DEFINED_FOR_ONLY_ONE_EVENT_HANDLER = 82
- RANDOM_FUNCTIONS_LEGALLY_USED = 113
- REPEATED_PRIORITY_VALUE = 83
- RESOLUTION_FUNC_USED = 112
- SEVERAL_LHS = 28
- SOFT_INCOMPATIBILITY = 44
- SPIKE_INPUT_PORT_IN_EQUATION_RHS_OUTSIDE_CONVOLVE = 120
- SPIKE_INPUT_PORT_TYPE_NOT_DEFINED = 10
- SPIKING_INPUT_PORT_NAME_ILLEGALLY_USED = 116
- START_PROCESSING_FILE = 0
- START_PROCESSING_MODEL = 12
- STATE_VARIABLES_NOT_INITIALZED = 76
- SYMBOL_NOT_RESOLVED = 48
- SYNAPSE_SOLVED_BY_GSL = 49
- SYNS_BAD_BUFFER_COUNT = 107
- TARGET_PATH_INFO = 67
- TEMPLATED_ARG_TYPES_INCONSISTENT = 65
- TEMPLATE_ROOT_PATH_CREATED = 78
- TIMESTEP_FUNCTION_LEGALLY_USED = 113
- TYPE_DIFFERENT_FROM_EXPECTED = 6
- TYPE_MISMATCH = 50
- TYPE_NOT_DERIVABLE = 3
- TYPE_NOT_SPECIFIED = 37
- UNKNOWN_TARGET = 61
- UNKNOWN_TYPE = 70
- VALUE_ASSIGNED_TO_BUFFER = 18
- VARIABLE_DEFINED_RECURSIVELY = 17
- VARIABLE_NOT_IN_STATE_BLOCK = 25
- VARIABLE_REDECLARED = 43
- VARIABLE_USED_BEFORE_DECLARATION = 16
- VARIABLE_WITH_SAME_NAME_AS_UNIT = 62
- VECTOR_IN_NON_VECTOR = 42
- VECTOR_PARAMETER_WRONG_BLOCK = 79
- VECTOR_PARAMETER_WRONG_SIZE = 81
- VECTOR_PARAMETER_WRONG_TYPE = 80
- VOID_FUNCTION_ON_RHS = 110
- WEIGHT_VARIABLE_NOT_SPECIFIED = 122
- WRONG_NUMBER_OF_ARGS = 26
- class pynestml.utils.messages.Messages
Bases:
objectThis class contains a collection of error messages which enables a centralized maintaining and modifications of those.
- classmethod astdatatype_type_symbol_could_not_be_derived() Tuple[MessageCode, str]
Unknown type or unit literal. :param provided_type_str: the provided type as a string
- classmethod delta_function_cannot_be_mixed() Tuple[MessageCode, str]
Delta function cannot be mixed with expressions.
- classmethod delta_function_one_arg(deltafunc: ASTFunctionCall) Tuple[MessageCode, str]
Delta function takes exactly one argument. :param deltafunc: the delta function node
- classmethod get_assigning_to_inline() Tuple[MessageCode, str]
Cannot assign to inline expression :return: a code, message tuple
- classmethod get_assignment_not_allowed(name: str) Tuple[MessageCode, str]
Indicates that an assignment to the given element is not allowed. :param name: the name of variable to which an assignment is not allowed. :return: a message
- classmethod get_binary_operation_not_defined(lhs, operator, rhs) Tuple[MessageCode, str]
- classmethod get_binary_operation_type_could_not_be_derived(lhs, operator, rhs, lhs_type, rhs_type) Tuple[MessageCode, str]
- classmethod get_block_not_defined_correctly(block: str, missing: bool) Tuple[MessageCode, str]
Indicates that a given block has been defined several times or non. :param block: the name of the block which is not defined or defined multiple times. :param missing: True if missing, False if multiple times. :return: a message
- classmethod get_cm_inline_expression_variable_used_mulitple_times(cm_inline_expr: ASTInlineExpression, bad_variable_name: str, ion_channel_name: str) Tuple[MessageCode, str]
- classmethod get_cm_variable_value_missing(varname: str) Tuple[MessageCode, str]
- classmethod get_code_generated(model_name: str, path: str) Tuple[MessageCode, str]
Returns a message indicating that code has been successfully generated for a model in a certain path. :param model_name: the name of the model. :param path: the path to the file :return: a message
- classmethod get_comparison(message_code: MessageCode) Tuple[MessageCode, str]
construct an error message indicating that an a comparison operation has incompatible operands :return: the error message
- classmethod get_compilation_unit_name_collision(name: str, art1: str, art2: str) Tuple[MessageCode, str]
Indicates that a name collision with the same model inside two artifacts. :param name: the name of the model which leads to collision :param art1: the first artifact name :param art2: the second artifact name :return: a message
- classmethod get_convolve_needs_buffer_parameter() Tuple[MessageCode, str]
- classmethod get_could_not_resolve(name: str) Tuple[MessageCode, str]
Indicates that the handed over name could not be resolved to a symbol. :param name: the name which could not be resolved :return: a message
- classmethod get_creating_install_path(install_path: str) Tuple[MessageCode, str]
- classmethod get_creating_target_path(target_path: str) Tuple[MessageCode, str]
- classmethod get_data_type_not_specified(name: str) Tuple[MessageCode, str]
Indicates that for a given element no type has been specified. :param name: the name of the variable for which a type has not been specified. :return: a message
- classmethod get_delay_variable_not_found(variable_name: str) Tuple[MessageCode, str]
- classmethod get_different_type_rhs_lhs(rhs_expression: ASTExpression | ASTSimpleExpression, lhs_expression: ASTExpression | ASTSimpleExpression, rhs_type: TypeSymbol, lhs_type: TypeSymbol) Tuple[MessageCode, str]
Returns a message indicating that the type of the lhs does not correspond to the one of the rhs and can not be cast down to a common type. :param rhs_expression: the rhs rhs :param lhs_expression: the lhs rhs :param rhs_type: the type of the rhs :param lhs_type: the type of the lhs :return: a message
- classmethod get_emit_spike_function_but_no_output_port() Tuple[MessageCode, str]
Indicates that an emit_spike() function was called, but no spiking output port has been defined. :return: a (code, message) tuple
- classmethod get_equation_var_not_in_state_block(variable_name: str) Tuple[MessageCode, str]
Indicates that a variable in the equations block is not defined in the state block. :param variable_name: the name of the variable of an equation which is not defined in an equations block :return: a message
- classmethod get_equations_defined_but_integrate_odes_not_called() Tuple[MessageCode, str]
- classmethod get_expected_cm_function_bad_return_type(ion_channel_name: str, astfun: ASTFunction) Tuple[MessageCode, str]
- classmethod get_expected_cm_function_missing(ion_channel_name: str, variable_name: str, function_name: str) Tuple[MessageCode, str]
- classmethod get_expected_cm_function_wrong_args_count(ion_channel_name: str, variable_name, astfun: ASTFunction) Tuple[MessageCode, str]
- classmethod get_expected_cm_variables_missing_in_blocks(missing_variable_to_proper_block: Iterable, expected_variables_to_reason: dict) Tuple[MessageCode, str]
- classmethod get_first_arg_not_kernel_or_equation(func_name: str) Tuple[MessageCode, str]
Indicates that the first argument of an rhs is not an equation or kernel. :param func_name: the name of the function :return: a message
- classmethod get_fixed_timestep_func_used() Tuple[MessageCode, str]
- classmethod get_function_call_implicit_cast(arg_nr: int, function_call, expected_type, got_type, castable: bool = False) Tuple[MessageCode, str]
Returns a message indicating that an implicit cast has been performed. :param arg_nr: the number of the argument which is cast :param function_call: a single function call :param expected_type: the expected type :param got_type: the got-type :param castable: is the type castable :return: a message
- classmethod get_function_is_delay_variable(func) Tuple[MessageCode, str]
- classmethod get_function_not_declared(name: str) Tuple[MessageCode, str]
Indicates that a function, which is not declared, has been used. :param name: the name of the function. :return: a message
- classmethod get_function_redeclared(name: str, predefined: bool) Tuple[MessageCode, str]
Indicates that a function has been redeclared. :param name: the name of the function which has been redeclared. :param predefined: True if function is predefined, otherwise False. :return: a message
- classmethod get_implicit_cast_rhs_to_lhs(rhs_type: str, lhs_type: str) Tuple[MessageCode, str]
Returns a message indicating that the type of the lhs does not correspond to the one of the rhs, but the rhs can be cast down to lhs type. :param rhs_type: the type of the rhs :param lhs_type: the type of the lhs :return: a message
- classmethod get_implicit_magnitude_conversion(lhs, rhs, conversion_factor) Tuple[MessageCode, str]
- classmethod get_input_path_not_found(path) Tuple[MessageCode, str]
- classmethod get_input_port_size_not_greater_than_zero(port_name: str) Tuple[MessageCode, str]
- classmethod get_input_port_size_not_integer(port_name: str) Tuple[MessageCode, str]
- classmethod get_input_port_type_not_defined(input_port_name: str) Tuple[MessageCode, str]
Returns a message indicating that a input_port type has not been defined, thus nS is assumed. :param input_port_name: a input_port name :return: a message
- classmethod get_install_path_info(install_path: str) Tuple[MessageCode, str]
- classmethod get_integrate_odes_arg_higher_order(arg: str) Tuple[MessageCode, str]
- classmethod get_integrate_odes_wrong_arg(arg: str) Tuple[MessageCode, str]
- classmethod get_kernel_iv_wrong_type(iv_name: str, actual_type: str, expected_type: str) Tuple[MessageCode, str]
Returns a message indicating that the type of a kernel initial value is wrong. :param iv_name: the name of the state variable with an initial value :param actual_type: the name of the actual type that was found in the model :param expected_type: the name of the type that was expected
- classmethod get_kernel_outside_convolve(name: str) Tuple[MessageCode, str]
Indicates that a kernel variable has been used outside a convolve call. :param name: the name of the kernel :return: message
- classmethod get_kernel_wrong_type(kernel_name: str, differential_order: int, actual_type: str) Tuple[MessageCode, str]
Returns a message indicating that the type of a kernel is wrong. :param kernel_name: the name of the kernel :param differential_order: differential order of the kernel left-hand side, e.g. 2 if the kernel is g”” :param actual_type: the name of the actual type that was found in the model
- classmethod get_lexer_error(msg) Tuple[MessageCode, str]
- classmethod get_mechs_dictionary_info(chan_info, syns_info, conc_info, con_in_info) Tuple[MessageCode, str]
- classmethod get_mismatch() Tuple[MessageCode, str]
construct an error message indicating that an a comparison operation has incompatible operands :return: the error message
- classmethod get_model_contains_errors(model_name: str) Tuple[MessageCode, str]
Returns a message indicating that a model contains errors thus no code is generated. :param model_name: the name of the model :return: a message
- classmethod get_model_redeclared(name: str) Tuple[MessageCode, str]
Indicates that a model has been redeclared. :param name: the name of the model which has been redeclared. :return: a message
- classmethod get_module_generated(path: str) Tuple[MessageCode, str]
Returns a message indicating that a module has been successfully generated. :param path: the path to the generated file :return: a message
- classmethod get_multiple_keywords(keyword: str) Tuple[MessageCode, str]
Indicates that a buffer has been declared with multiple keywords of the same type, e.g., inhibitory inhibitory :param keyword: the keyword which has been used multiple times :return: a message
- classmethod get_nest_collision(name: str) Tuple[MessageCode, str]
Indicates that a collision between a user defined function and a nest function occurred. :param name: the name of the function which collides to nest :return: a message
- classmethod get_no_code_generated() Tuple[MessageCode, str]
Returns a message indicating that no code will be generated on this run. :return: a message
- classmethod get_no_files_in_input_path(path: str) Tuple[MessageCode, str]
- classmethod get_no_gating_variables(cm_inline_expr: ASTInlineExpression, ion_channel_name: str) Tuple[MessageCode, str]
Indicates that if you defined an inline expression inside the equations block that uses no kernels / has no convolution calls then then there must be at least one variable name that ends with _{x} For example an inline “Na” must have at least one variable ending with “_Na” :return: a message
- classmethod get_no_init_value(name: str) Tuple[MessageCode, str]
Indicates that no initial value has been provided for a given variable. :param name: the name of the variable which does not have a initial value :return: a message
- classmethod get_no_ode(name: str) Tuple[MessageCode, str]
Indicates that no ODE has been defined for a variable inside the state block. :param name: the name of the variable which does not have a defined ode :return: a message
- classmethod get_no_return() Tuple[MessageCode, str]
Indicates that a given function has no return statement although required. :return: a message
- classmethod get_no_rhs(name: str) Tuple[MessageCode, str]
Indicates that no right-hand side has been declared for the given variable. :param name: the name of the rhs variable :return: a message
- classmethod get_no_variable_found(variable_name: str) Tuple[MessageCode, str]
Returns a message indicating that a variable has not been found. :param variable_name: the name of the variable :return: a message
- classmethod get_non_constant_exponent() Tuple[MessageCode, str]
construct an error message indicating that the exponent given to a unit base is not a constant value :return: the error message
- classmethod get_not_a_variable(name: str) Tuple[MessageCode, str]
Indicates that a given name does not represent a variable. :param name: the name of the variable :return: a message
- classmethod get_not_last_statement(name: str) Tuple[MessageCode, str]
Indicates that given statement is not the last statement in a block, e.g., in the case that a return statement is not the last statement. :param name: the statement. :return: a message
- classmethod get_not_neuroscience_unit_used(name: str) Tuple[MessageCode, str]
Indicates that a non-neuroscientific unit, e.g., kg, has been used. Those units can not be converted to a corresponding representation in the simulation and are therefore represented by the factor 1. :param name: the name of the variable :return: a nes code,message tuple
- classmethod get_not_type_allowed(name: str) Tuple[MessageCode, str]
Indicates that a type for the given element is not allowed. :param name: the name of the element for which a type is not allowed. :return: a message
- classmethod get_ode_function_needs_consistent_units(name: str, declared_type, expression_type) Tuple[MessageCode, str]
- classmethod get_ode_needs_consistent_units(name: str, differential_order: int, lhs_type, rhs_type) Tuple[MessageCode, str]
- classmethod get_order_not_declared(lhs: str) Tuple[MessageCode, str]
Indicates that the order has not been declared. :param lhs: the name of the variable :return: a message
- classmethod get_parser_error(msg) Tuple[MessageCode, str]
- classmethod get_priority_defined_for_only_one_receive_block(event_handler_port_name: str) Tuple[MessageCode, str]
- classmethod get_random_functions_legally_used(name: str) Tuple[MessageCode, str]
- classmethod get_repeated_priorty_value() Tuple[MessageCode, str]
- classmethod get_second_arg_not_a_spike_port(func_name: str) Tuple[MessageCode, str]
Indicates that the second argument of the NESTML convolve() call is not a spiking input port. :param func_name: the name of the function :return: a message
- classmethod get_several_lhs(names: List[str]) Tuple[MessageCode, str]
Indicates that several left hand sides have been defined. :param names: a list of variables :return: a message
- classmethod get_spike_input_port_appears_outside_equation_rhs_and_event_handler(name)
- classmethod get_spike_input_port_in_equation_rhs_outside_convolve()
- classmethod get_start_code_generation(name: str) Tuple[MessageCode, str]
Indicates start of code generation :param name: the name of the model :return: a code, message tuple
- classmethod get_start_processing_file(file_path: str) Tuple[MessageCode, str]
Returns a message indicating that processing of a file has started :param file_path: the path to the file :return: message code tuple
- classmethod get_start_processing_model(model_name: str) Tuple[MessageCode, str]
Returns a message indicating that the processing of a model is started. :param model_name: the name of the model :return: a message
- classmethod get_state_variables_not_initialized(var_name: str) Tuple[MessageCode, str]
- classmethod get_target_path_info(target_dir: str) Tuple[MessageCode, str]
- classmethod get_template_root_path_created(templates_root_dir: str) Tuple[MessageCode, str]
- classmethod get_ternary_mismatch(if_true_text: str, if_not_text: str) Tuple[MessageCode, str]
construct an error message indicating that an a comparison operation has incompatible operands :param if_true_text: plain text of the positive branch of the ternary operator :param if_not_text: plain text of the negative branch of the ternary operator :return: the error message
- classmethod get_timestep_function_legally_used() Tuple[MessageCode, str]
- classmethod get_type_could_not_be_derived(rhs: ASTExpression | ASTSimpleExpression) Tuple[MessageCode, str]
Returns a message indicating that the type of the rhs rhs could not be derived. :param rhs: an rhs :return: a message
- classmethod get_type_different_from_expected(expected_type, got_type) Tuple[MessageCode, str]
Returns a message indicating that the received type is different from the expected one. :param expected_type: the expected type :param got_type: the actual type :return: a message
- classmethod get_unary_operation_not_defined(operator, term) Tuple[MessageCode, str]
- classmethod get_unit_base() Tuple[MessageCode, str]
construct an error message indicating that a non-int type was given as exponent to a unit type :return: the error message
- classmethod get_unit_does_not_exist(name: str) Tuple[MessageCode, str]
Indicates that a unit does not exist. :param name: the name of the unit. :return: a new code,message tuple
- classmethod get_unknown_target_platform(target: str) Tuple[MessageCode, str]
- classmethod get_v_comp_variable_value_missing(neuron_name: str, missing_variable_name) Tuple[MessageCode, str]
- classmethod get_value_assigned_to_buffer(buffer_name: str) Tuple[MessageCode, str]
Returns a message indicating that a value has been assigned to a buffer. :param buffer_name: a buffer name :return: a message
- classmethod get_variable_defined_recursively(variable_name: str) Tuple[MessageCode, str]
Returns a message indicating that a variable is defined recursively. :param variable_name: a variable name :return: a message
- classmethod get_variable_not_defined(variable_name: str) Tuple[MessageCode, str]
Returns a message indicating that a variable is not defined . :param variable_name: a variable name :return: a message
- classmethod get_variable_redeclared(name: str, predefined: bool) Tuple[MessageCode, str]
Indicates that a given variable has been redeclared. A redeclaration can happen with user defined functions or with predefined functions (second parameter). :param name: the name of the variable :param predefined: True if a pre-defined variable has been redeclared, otherwise False. :return: a message
- classmethod get_variable_used_before_declaration(variable_name: str) Tuple[MessageCode, str]
Returns a message indicating that a variable is used before declaration. :param variable_name: a variable name :return: a message
- classmethod get_variable_with_same_name_as_type(name: str) Tuple[MessageCode, str]
Indicates that a variable has been declared with the same name as a physical unit, e.g. “V mV” :param name: the name of the variable :return: a tuple containing message code and message text
- classmethod get_vector_in_non_vector(vector: str, non_vector: str) Tuple[MessageCode, str]
Indicates that a vector has been used in a non-vector declaration. :param vector: the vector variable :param non_vector: the non-vector lhs :return: a message
- classmethod get_vector_input_ports_should_be_of_constant_size()
- classmethod get_vector_parameter_wrong_block(var, block) Tuple[MessageCode, str]
- classmethod get_vector_parameter_wrong_size(var, value) Tuple[MessageCode, str]
- classmethod get_vector_parameter_wrong_type(var) Tuple[MessageCode, str]
- classmethod get_void_function_on_rhs(function_name: str) Tuple[MessageCode, str]
Construct an error message indicating that a void function cannot be used on a RHS. :param function_name: the offending function :return: the error message
- classmethod get_weight_variable_not_found(variable_name: str) Tuple[MessageCode, str]
- classmethod get_weight_variable_not_specified() Tuple[MessageCode, str]
- classmethod get_wrong_number_of_args(function_call: str, expected: int, got: int) Tuple[MessageCode, str]
Indicates that a wrong number of arguments has been provided to the function call. :param function_call: a function call name :param expected: the expected number of arguments :param got: the given number of arguments :return: a message
- classmethod get_wrong_numerator(unit: str) Tuple[MessageCode, str]
Indicates that the numerator of a unit is not 1. :param unit: the name of the unit :return: a message
- classmethod templated_arg_types_inconsistent(function_name, failing_arg_idx, other_args_idx, failing_arg_type_str, other_type_str) Tuple[MessageCode, str]
For templated function arguments, indicates inconsistency between (formal) template argument types and actual derived types. :param name: the name of the model :return: a code, message tuple
- classmethod unknown_type(provided_type_str: str) Tuple[MessageCode, str]
Unknown type or unit literal. :param provided_type_str: the provided type as a string
pynestml.utils.model_parser module
- class pynestml.utils.model_parser.BailConsoleErrorListener
Bases:
ErrorListenerPrint error message to the console as well as bail
- syntaxError(recognizer, offendingSymbol, line, column, msg, e)
- class pynestml.utils.model_parser.ModelParser
Bases:
object- classmethod parse_assignment(string: str) ASTAssignment
- classmethod parse_bit_operator(string: str) ASTArithmeticOperator
- classmethod parse_block_with_variables(string: str) ASTBlockWithVariables
- classmethod parse_comparison_operator(string: str) ASTComparisonOperator
- classmethod parse_compound_stmt(string: str) ASTCompoundStmt
- classmethod parse_data_type(string: str) ASTDataType
- classmethod parse_declaration(string: str) ASTDeclaration
- classmethod parse_elif_clause(string: str) ASTElifClause
- classmethod parse_else_clause(string: str) ASTElseClause
- classmethod parse_equations_block(string: str) ASTEquationsBlock
- classmethod parse_expression(string: str) ASTExpression
- classmethod parse_file(file_path=None)
Parses a handed over model and returns the meta_model representation of it. :param file_path: the path to the file which shall be parsed. :type file_path: str :return: a new ASTNESTMLCompilationUnit object. :rtype: ASTNestMLCompilationUnit
- classmethod parse_for_stmt(string: str) ASTForStmt
- classmethod parse_function(string: str) ASTFunction
- classmethod parse_function_call(string: str) ASTFunctionCall
- classmethod parse_if_clause(string: str) ASTIfClause
- classmethod parse_inline_expression(string: str) ASTInlineExpression
- classmethod parse_input_block(string: str) ASTInputBlock
- classmethod parse_input_port(string: str) ASTInputPort
- classmethod parse_logic_operator(string: str) ASTLogicalOperator
- classmethod parse_model_body(string: str) ASTModelBody
- classmethod parse_nestml_compilation_unit(string: str) ASTNestMLCompilationUnit
- classmethod parse_ode_equation(string: str) ASTOdeEquation
- classmethod parse_output_block(string: str) ASTOutputBlock
- classmethod parse_parameter(string: str) ASTParameter
- classmethod parse_return_stmt(string: str) ASTReturnStmt
- classmethod parse_simple_expression(string: str) ASTSimpleExpression
- classmethod parse_small_stmt(string: str) ASTSmallStmt
- classmethod parse_stmts_body(string: str) ASTStmtsBody
- classmethod parse_unary_operator(string: str) ASTUnaryOperator
- classmethod parse_unit_type(string: str) ASTUnitType
- classmethod parse_update_block(string: str) ASTUpdateBlock
- classmethod parse_variable(string: str) ASTVariable
- classmethod parse_while_stmt(string: str) ASTWhileStmt
- pynestml.utils.model_parser.log_set_added_source_position(node)
- pynestml.utils.model_parser.tokenize(string: str) Tuple[ASTBuilderVisitor, PyNestMLParser]
pynestml.utils.ode_toolbox_utils module
pynestml.utils.port_signal_type module
pynestml.utils.stack module
- class pynestml.utils.stack.Stack
Bases:
objectThis class represents a simple version of a stack.
- is_empty()
Returns true if this stack is empty. :return: True if empty, otherwise False. :rtype: bool
- pop()
Returns the last element on the stack. :return: a single object if not empty, otherwise None :rtype: object
- pop_first()
Returns the first element on the stack. :return: a single object if not empty, otherwise None :rtype: object
- pop_n_first_to_list(n)
Pops the first n items and returns them in a list :param n: the number of items :return: int
- pop_n_to_list(n)
Pops the first n items and returns them in a list :param n: the number of items :return: int
- push(elem)
Pushes an element to the stack :param elem: a single element :type elem: object
- top()
pynestml.utils.string_utils module
pynestml.utils.synapse_processing module
- class pynestml.utils.synapse_processing.SynapseProcessing(params)
Bases:
MechanismProcessing- classmethod collect_additional_base_infos(neuron, syns_info)
Collect internals, kernels, inputs and convolutions associated with the synapse.
- classmethod collect_information_for_specific_mech_types(neuron, mechs_info)
- classmethod convolution_ode_toolbox_processing(neuron, syns_info)
- classmethod create_ode_indict(neuron: ASTModel, parameters_block: ASTBlockWithVariables, kernel_buffer)
- mechType = 'receptor'
- classmethod ode_solve_convolution(neuron: ASTModel, parameters_block: ASTBlockWithVariables, kernel_buffer)
- classmethod transform_ode_and_kernels_to_json(neuron: ASTModel, parameters_block, kernel_buffers)
Converts AST node to a JSON representation suitable for passing to ode-toolbox.
Each kernel has to be generated for each spike buffer convolve in which it occurs, e.g. if the NESTML model code contains the statements
convolve(G, ex_spikes) convolve(G, in_spikes)
then kernel_buffers will contain the pairs (G, ex_spikes) and (G, in_spikes), from which two ODEs will be generated, with dynamical state (variable) names G__X__ex_spikes and G__X__in_spikes.
- Parameters:
parameters_block – ASTBlockWithVariables
- Returns:
Dict
pynestml.utils.syns_info_enricher module
- class pynestml.utils.syns_info_enricher.ASTUsedVariableNamesExtractor(node)
Bases:
ASTVisitor- visit_variable(node)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
- class pynestml.utils.syns_info_enricher.SynsInfoEnricher(params)
Bases:
MechsInfoEnricherinput: a neuron after ODE-toolbox transformations
the kernel analysis solves all kernels at the same time this splits the variables on per kernel basis
- classmethod compute_expression_derivative(inline_expression: ASTInlineExpression) ASTExpression
- classmethod enrich_mechanism_specific(neuron, mechs_info)
- classmethod get_all_synapse_variables(single_synapse_info)
returns all variable names referenced by the synapse inline and by the analytical solution assumes that the model has already been transformed
- classmethod get_analytic_helper_variable_declarations(single_synapse_info)
- classmethod get_analytic_helper_variable_names(single_synapse_info)
get new variables that only occur on the right hand side of analytic solution Expressions but for wich analytic solution does not offer any values this can isolate out additional variables that suddenly appear such as __h whose initial values are not inlcuded in the output of analytic solver
- classmethod get_new_variables_after_transformation(single_synapse_info)
- classmethod restore_order_internals(neuron: ASTModel, cm_syns_info: dict)
orders user defined internals back to the order they were originally defined this is important if one such variable uses another user needs to have control over the order assign each variable a rank that corresponds to the order in SynsInfoEnricher.declarations_ordered
- class pynestml.utils.syns_info_enricher.SynsInfoEnricherVisitor
Bases:
ASTVisitor- declarations_ordered = []
- endvisit_block_with_variables(node)
Used to endvisit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- endvisit_declaration(node)
Used to endvisit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- endvisit_inline_expression(node)
Used to endvisit a single inline expression. :param node: a single inline expression :type node: ASTInlineExpression
- endvisit_simple_expression(node)
Used to endvisit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
- inline_name_to_transformed_inline = {}
- internal_variable_name_to_variable = {}
- variables_to_internal_declarations = {}
- visit_block_with_variables(node)
Used to visit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- visit_declaration(node)
Used to visit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- visit_inline_expression(node)
Used to visit a single inline expression. :param node: a single inline expression. :type node: ASTInlineExpression
- visit_simple_expression(node)
Used to visit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
pynestml.utils.type_caster module
- class pynestml.utils.type_caster.TypeCaster
Bases:
object- static do_magnitude_conversion_rhs_to_lhs(_rhs_type_symbol, _lhs_type_symbol, _containing_expression)
Determine conversion factor from rhs to lhs, register it with the relevant expression
- static try_to_recover_or_error(_lhs_type_symbol, _rhs_type_symbol, _containing_expression, set_implicit_conversion_factor_on_lhs=False)
pynestml.utils.type_dictionary module
pynestml.utils.unit_type module
- class pynestml.utils.unit_type.UnitType(name, unit)
Bases:
objectThis class is used to encapsulate the functionality of astropy.units in a new layer which provided additional functionality as required during context checks.
- Attr name:
The name of this unit.
- Attr unit:
The corresponding astropy Unit.
- equals(_obj=None)
Compares this to the handed object and checks if they are semantically equal. :param _obj: a single object :type _obj: object :return: True if equal, otherwise false. :rtype: bool
- get_name()
Returns the name of this unit. :return: the name of the unit. :rtype: str
- get_unit()
Returns the astropy unit of this unit. :return: the astropy unit :rtype: astropy.units.core.Unit
- print_unit()
Returns a string representation of this unit symbol. :return: a string representation. :rtype: str
pynestml.utils.with_options module
- class pynestml.utils.with_options.WithOptions(options: Mapping[str, Any] | None = None)
Bases:
objectThis class allows options (indexed by strings) to be set and retrieved. A set of default options may be supplied by overriding the _default_options member in the inheriting class.