pynestml.cocos package

Submodules

pynestml.cocos.co_co module

class pynestml.cocos.co_co.CoCo

Bases: object

This class represents an abstract super-class for all concrete context conditions to check. All concrete CoCos have to inherit from this class. Hereby, the description can be used to state the condition the CoCo checks. .. attribute:: description type

This field can be used to give a short description regarding the properties which are checked by this coco.

type:

str

abstract check_co_co(node)

This is an abstract method which should be implemented by all concrete cocos. :param node: a single neuron instance on which the coco will be checked. :type node: ast_neuron :return: True, if CoCo holds, otherwise False. :rtype: bool

description = None

pynestml.cocos.co_co_all_variables_defined module

class pynestml.cocos.co_co_all_variables_defined.ASTExpressionCollectorVisitor

Bases: ASTVisitor

traverse_expression(node)
traverse_simple_expression(node)
visit_assignment(node)

Used to visit a single assignment. :param node: an assignment object. :type node: ASTAssignment

visit_expression(node)

Used to visit a single rhs. :param node: an rhs. :type node: ASTExpression

visit_simple_expression(node)

Used to visit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression

class pynestml.cocos.co_co_all_variables_defined.CoCoAllVariablesDefined

Bases: CoCo

This class represents a constraint condition which ensures that all elements as used in expressions have been previously defined. Not allowed:

state:

V_m mV = V_m + 10mV # <- recursive definition V_m mV = V_n # <- not defined reference

classmethod check_co_co(node: ASTNeuron, after_ast_rewrite: bool = False)

Checks if this coco applies for the handed over neuron. Models which contain undefined variables are not correct. :param node: a single neuron instance. :param after_ast_rewrite: indicates whether this coco is checked after the code generator has done rewriting of the abstract syntax tree. If True, checks are not as rigorous. Use False where possible.

pynestml.cocos.co_co_cm_channel_model module

class pynestml.cocos.co_co_cm_channel_model.CoCoCmChannelModel

Bases: CoCo

classmethod check_co_co(neuron: ASTNeuron)

Checks if this compartmental condition applies to the handed over neuron. If yes, it checks the presence of expected functions and declarations. :param neuron: a single neuron instance. :type neuron: ast_neuron

pynestml.cocos.co_co_cm_concentration_model module

class pynestml.cocos.co_co_cm_concentration_model.CoCoCmConcentrationModel

Bases: CoCo

classmethod check_co_co(neuron: ASTNeuron)

Check if this compartmental condition applies to the handed over neuron. If yes, it checks the presence of expected functions and declarations. :param neuron: a single neuron instance. :type neuron: ast_neuron

pynestml.cocos.co_co_cm_synapse_model module

class pynestml.cocos.co_co_cm_synapse_model.CoCoCmSynapseModel

Bases: CoCo

classmethod check_co_co(neuron: ASTNeuron)

Checks if this compartmental condition applies to the handed over neuron. If yes, it checks the presence of expected functions and declarations. :param neuron: a single neuron instance. :type neuron: ast_neuron

pynestml.cocos.co_co_convolve_cond_correctly_built module

class pynestml.cocos.co_co_convolve_cond_correctly_built.CoCoConvolveCondCorrectlyBuilt

Bases: CoCo

This coco ensures that convolve is correctly called, i.e. that the first argument is the variable from the state block and the second argument is a spiking input port.

Allowed:

inline I_syn_exc pA = convolve(g_exc, exc_spikes) * ( V_m - E_exc )

Not allowed:

inline I_syn_exc pA = convolve(g_exc, g_exc) * ( V_m - E_exc ) inline I_syn_exc pA = convolve(exc_spikes, g_exc) * ( V_m - E_exc )

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_convolve_cond_correctly_built.ConvolveCheckerVisitor

Bases: ASTVisitor

Visits a function call and checks that if the function call is a convolve, the parameters are correct.

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

pynestml.cocos.co_co_correct_numerator_of_unit module

class pynestml.cocos.co_co_correct_numerator_of_unit.CoCoCorrectNumeratorOfUnit

Bases: CoCo

This coco ensures that all units which consist of a dividend and divisor, where the numerator is a numeric value, have 1 as the numerator. Allowed:

V_m 1/mV = …

Not allowed:

V_m 2/mV = …

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_correct_numerator_of_unit.NumericNumeratorVisitor

Bases: ASTVisitor

Visits a numeric numerator and checks if the value is 1.

visit_unit_type(node)

Check if the coco applies, :param node: a single unit type object. :type node: ast_unit_type

pynestml.cocos.co_co_correct_order_in_equation module

class pynestml.cocos.co_co_correct_order_in_equation.CoCoCorrectOrderInEquation

Bases: CoCo

This coco ensures that whenever a ode-equation is assigned to a variable, it have a differential order of at leas one. Allowed:

equations:

V_m’ = …

Not allowed:
equations:

V_m = …

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_correct_order_in_equation.OrderOfEquationVisitor

Bases: ASTVisitor

This visitor checks that all differential equations have a differential order.

visit_ode_equation(node)

Checks the coco. :param node: A single ode equation. :type node: ast_ode_equation

pynestml.cocos.co_co_each_block_defined_at_most_once module

class pynestml.cocos.co_co_each_block_defined_at_most_once.CoCoEachBlockDefinedAtMostOnce

Bases: CoCo

This context condition ensures that each block is defined at most once.

Not allowed:

state:
    ...
...
state:
    ...
classmethod check_co_co(node: ASTNeuron | ASTSynapse)

Checks whether each block is define at most once. :param node: a single neuron or synapse.

pynestml.cocos.co_co_equations_only_for_init_values module

class pynestml.cocos.co_co_equations_only_for_init_values.CoCoEquationsOnlyForInitValues

Bases: CoCo

This coco ensures that ode equations are only provided for variables which have been defined in the state block. Allowed:

Not allowed:

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_equations_only_for_init_values.EquationsOnlyForInitValues

Bases: ASTVisitor

This visitor ensures that for all ode equations exists an initial value in the state block.

visit_ode_equation(node)

Ensures the coco. :param node: a single equation object. :type node: ast_ode_equation

pynestml.cocos.co_co_function_argument_template_types_consistent module

class pynestml.cocos.co_co_function_argument_template_types_consistent.CoCoFunctionArgumentTemplateTypesConsistent

Bases: CoCo

This coco checks that if template types are used for function parameters, the types are mutually consistent.

classmethod check_co_co(neuron)

Ensures the coco for the handed over neuron. :param neuron: a single neuron instance. :type neuron: ASTNeuron

class pynestml.cocos.co_co_function_argument_template_types_consistent.CorrectTemplatedArgumentTypesVisitor

Bases: ASTVisitor

This visitor checks that all expression correspond to the expected type.

visit_simple_expression(node)

Visits a single function call as stored in a simple expression and, if template types are used for function parameters, checks if all actual parameter types are mutually consistent.

Parameters:

node (ASTSimpleExpression) – a simple expression

Rtype None:

pynestml.cocos.co_co_function_calls_consistent module

class pynestml.cocos.co_co_function_calls_consistent.CoCoFunctionCallsConsistent

Bases: CoCo

This context condition checker ensures that for all function calls in the handed over neuron, if the called function has been declared, whether the number and types of arguments correspond to the declaration, etc.

classmethod check_co_co(node)

Checks the coco for the handed over neuron. :param node: a single neuron instance. :type node: ASTNeuron

class pynestml.cocos.co_co_function_calls_consistent.FunctionCallConsistencyVisitor

Bases: ASTVisitor

This visitor ensures that all function calls are consistent.

visit_function_call(node)

Check consistency for a single function call: check if the called function has been declared, whether the number and types of arguments correspond to the declaration, etc.

Parameters:

node (ASTFunctionCall) – a single function call.

pynestml.cocos.co_co_function_unique module

class pynestml.cocos.co_co_function_unique.CoCoFunctionUnique

Bases: CoCo

This Coco ensures that each function is defined exactly once (thus no redeclaration occurs).

classmethod check_co_co(node)

Checks if each function is defined uniquely. :param node: a single neuron :type node: ast_neuron

pynestml.cocos.co_co_illegal_expression module

class pynestml.cocos.co_co_illegal_expression.CoCoIllegalExpression

Bases: CoCo

This coco checks that all expressions are correctly typed.

classmethod check_co_co(neuron)

Ensures the coco for the handed over neuron. :param neuron: a single neuron instance. :type neuron: ASTNeuron

class pynestml.cocos.co_co_illegal_expression.CorrectExpressionVisitor

Bases: ASTVisitor

This visitor checks that all expression correspond to the expected type.

handle_compound_assignment(node)
handle_simple_assignment(node)
visit_assignment(node)

Visits a single expression and assures that type(lhs) == type(rhs). :param node: a single assignment. :type node: ASTAssignment

visit_declaration(node)

Visits a single declaration and asserts that type of lhs is equal to type of rhs. :param node: a single declaration. :type node: ASTDeclaration

visit_elif_clause(node)

Visits a single elif clause and checks that its condition is boolean. :param node: a single elif clause. :type node: ASTElifClause

visit_for_stmt(node)

Visits a single for stmt and checks that all it parts are correctly defined. :param node: a single for stmt :type node: ASTForStmt

visit_if_clause(node)

Visits a single if clause and checks that its condition is boolean. :param node: a single elif clause. :type node: ASTIfClause

visit_inline_expression(node)

Visits a single inline expression and asserts that type of lhs is equal to type of rhs.

visit_while_stmt(node)

Visits a single while stmt and checks that its condition is of boolean type. :param node: a single while stmt :type node: ASTWhileStmt

pynestml.cocos.co_co_inline_expression_not_assigned_to module

class pynestml.cocos.co_co_inline_expression_not_assigned_to.CoCoInlineExpressionNotAssignedTo

Bases: CoCo

This coco ensures that no values are assigned to inline expressions.

classmethod check_co_co(node: ASTNeuron)

Ensures the coco for the handed over neuron. :param node: a single neuron instance.

class pynestml.cocos.co_co_inline_expression_not_assigned_to.NoInlineExpressionAssignedToVisitor

Bases: ASTVisitor

visit_assignment(node)

Used to visit a single assignment. :param node: an assignment object. :type node: ASTAssignment

pynestml.cocos.co_co_inline_expressions_have_rhs module

class pynestml.cocos.co_co_inline_expressions_have_rhs.CoCoInlineExpressionsHaveRhs

Bases: CoCo

This coco ensures that all inline expressions have a rhs.

classmethod check_co_co(node: ASTNeuron)

Ensures the coco for the handed over neuron. :param node: a single neuron instance.

class pynestml.cocos.co_co_inline_expressions_have_rhs.InlineRhsVisitor

Bases: ASTVisitor

This visitor ensures that everything declared as inline expression has a rhs.

visit_declaration(node: ASTDeclaration)

Checks if the coco applies. :param node: a single declaration.

pynestml.cocos.co_co_inline_max_one_lhs module

class pynestml.cocos.co_co_inline_max_one_lhs.CoCoInlineMaxOneLhs

Bases: CoCo

This coco ensures that whenever an inline expression is declared, only one left-hand side is present. Allowed:

inline V_rest mV = V_m - 55mV

Not allowed:

inline V_reset, V_rest mV = V_m - 55mV

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_inline_max_one_lhs.InlineMaxOneLhs

Bases: ASTVisitor

This visitor ensures that every inline expression has exactly one lhs.

visit_declaration(node: ASTDeclaration)

Checks the coco. :param node: a single declaration.

pynestml.cocos.co_co_input_port_not_assigned_to module

class pynestml.cocos.co_co_input_port_not_assigned_to.CoCoInputPortNotAssignedTo

Bases: CoCo

This coco ensures that no values are assigned to input ports.

Given:

input:
    current_in pA <- continuous

Allowed:

foo = current_in + 10 pA

Not allowed:

current_in = foo + 10 pA
classmethod check_co_co(node: ASTNeuron)

Ensures the coco for the handed over neuron. :param node: a single neuron instance.

class pynestml.cocos.co_co_input_port_not_assigned_to.NoInputPortAssignedToVisitor

Bases: ASTVisitor

visit_assignment(node)

Used to visit a single assignment. :param node: an assignment object. :type node: ASTAssignment

pynestml.cocos.co_co_input_port_qualifier_unique module

class pynestml.cocos.co_co_input_port_qualifier_unique.CoCoInputPortQualifierUnique

Bases: CoCo

This coco ensures that each spike input port has at most one type of modifier inhibitory and excitatory.

Allowed:

spike pA <- inhibitory spike

Not allowed:

spike pA <- inhibitory inhibitory spike
classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_input_port_qualifier_unique.InputPortQualifierUniqueVisitor

Bases: ASTVisitor

This visitor ensures that all input ports are qualified uniquely by keywords.

visit_input_port(node)

Checks the coco on the current node. :param node: a single input port. :type node: ASTInputPort

pynestml.cocos.co_co_integrate_odes_called_if_equations_defined module

class pynestml.cocos.co_co_integrate_odes_called_if_equations_defined.CoCoIntegrateOdesCalledIfEquationsDefined

Bases: CoCo

This coco ensures that integrate_odes() is called if one or more dynamical equations are defined.

classmethod check_co_co(node: ASTNeuron)

Ensures the coco for the handed over neuron. :param node: a single neuron instance.

class pynestml.cocos.co_co_integrate_odes_called_if_equations_defined.EquationsDefinedVisitor

Bases: ASTVisitor

This visitor checks if equations are defined.

equations_defined() bool
visit_ode_equation(node)

Used to visit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation

class pynestml.cocos.co_co_integrate_odes_called_if_equations_defined.IntegrateOdesCalledVisitor

Bases: ASTVisitor

This visitor checks if integrate_odes() is called.

integrate_odes_called() bool
visit_function_call(node: ASTFunctionCall)

Private method: Used to visit a single function call and update its corresponding scope. :param node: a function call object. :type node: ASTFunctionCall

pynestml.cocos.co_co_internals_assigned_only_in_internals_block module

class pynestml.cocos.co_co_internals_assigned_only_in_internals_block.CoCoInternalsAssignedOnlyInInternalsBlock

Bases: CoCo

This coco checks that no internals are assigned outside the internals block.

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ASTNeuron

class pynestml.cocos.co_co_internals_assigned_only_in_internals_block.InternalsAssignmentVisitor

Bases: ASTVisitor

This visitor checks that no internals have been assigned outside the internals block.

visit_assignment(node: ASTAssignment) None

Checks the coco on the current node. :param node: a single node.

pynestml.cocos.co_co_invariant_is_boolean module

class pynestml.cocos.co_co_invariant_is_boolean.CoCoInvariantIsBoolean

Bases: CoCo

This coco checks that all invariants are of type boolean

classmethod check_co_co(neuron)

Ensures the coco for the handed over neuron. :param neuron: a single neuron instance. :type neuron: ast_neuron

class pynestml.cocos.co_co_invariant_is_boolean.InvariantTypeVisitor

Bases: ASTVisitor

Checks if for each invariant, the type is boolean.

visit_declaration(node)

Checks the coco for a declaration. :param node: a single declaration. :type node: ASTDeclaration

pynestml.cocos.co_co_kernel_type module

class pynestml.cocos.co_co_kernel_type.CoCoKernelType

Bases: CoCo

Ensures that all defined kernels are untyped (for direct functions of time), or have a type equivalent to 1/s**-order, where order is the differential order of the kernel (e.g. 2 for kernel g'' = ...).

classmethod check_co_co(node: ASTNeuron)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ASTNeuron

class pynestml.cocos.co_co_kernel_type.KernelTypeVisitor

Bases: ASTVisitor

This visitor checks if each kernel has the appropriate data type.

visit_kernel(node)

Checks the coco on the current node. :param node: AST kernel object :type node: ASTKernel

pynestml.cocos.co_co_nest_delay_decorator_specified module

class pynestml.cocos.co_co_nest_delay_decorator_specified.CoCoNESTDelayDecoratorSpecified

Bases: CoCo

This CoCo ensures that there is precisely one parameter decorated as “@nest::delay”.

classmethod check_co_co(node: ASTNeuronOrSynapse)

Checks if the coco applies for the node. :param node:

pynestml.cocos.co_co_neuron_name_unique module

class pynestml.cocos.co_co_neuron_name_unique.CoCoNeuronNameUnique

Bases: CoCo

This coco ensures that for all elements in a single compile units, the names of all neurons are pairwise distinct. Allowed:

neuron a:

… neuron b:

Not allowed:
neuron a:

… neuron a: <- neuron with the same name

classmethod check_co_co(compilation_unit)

Checks the coco for the handed over compilation unit. :param compilation_unit: a single compilation unit. :type compilation_unit: ASTCompilationUnit

pynestml.cocos.co_co_no_duplicate_compilation_unit_names module

class pynestml.cocos.co_co_no_duplicate_compilation_unit_names.CoCoNoDuplicateCompilationUnitNames

Bases: CoCo

This Coco checks that for a handed over list of compilation units, there are not two units that have the same name.

classmethod check_co_co(list_of_compilation_units)

Checks the coco. :param list_of_compilation_units: a list of compilation units. :type list_of_compilation_units: list(ASTNestMLCompilationUnit)

pynestml.cocos.co_co_no_kernels_except_in_convolve module

class pynestml.cocos.co_co_no_kernels_except_in_convolve.CoCoNoKernelsExceptInConvolve

Bases: CoCo

This CoCo ensures that kernel variables do not occur on the right hand side except in convolve(). Allowed:

kernel g_ex = … function I_syn_exc pA = convolve(g_ex, spikeExc) * ( V_m - E_ex )

Not allowed

kernel g_ex = … function I_syn_exc pA = g_ex * ( V_m - E_ex )

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_no_kernels_except_in_convolve.KernelCollectingVisitor

Bases: ASTVisitor

collect_kernels(neuron)

Collects all kernels in the model. :param neuron: a single neuron instance :type neuron: ast_neuron :return: a list of kernels. :rtype: list(str)

visit_kernel(node)

Collects the kernel. :param node: a single kernel node. :type node: ASTKernel

class pynestml.cocos.co_co_no_kernels_except_in_convolve.KernelUsageVisitor(_kernels=None)

Bases: ASTVisitor

visit_variable(node: ASTNode)

Visits each kernel and checks if it is used correctly. :param node: a single node.

work_on(neuron)

pynestml.cocos.co_co_no_nest_name_space_collision module

class pynestml.cocos.co_co_no_nest_name_space_collision.CoCoNoNestNameSpaceCollision

Bases: CoCo

This coco tests that no functions are defined which collide with the nest namespace, which are:

“update”, “calibrate”, “handle”, “connect_sender”, “check_connection”, “get_status”, “set_status”, “init_state_”, “init_buffers_

Allowed:

function fun(…)

Not allowed:

function handle(…) <- collision

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

nest_name_space = ['update', 'calibrate', 'handle', 'connect_sender', 'check_connection', 'get_status', 'set_status', 'init_state_', 'init_buffers_']

pynestml.cocos.co_co_ode_functions_have_consistent_units module

class pynestml.cocos.co_co_ode_functions_have_consistent_units.CoCoOdeFunctionsHaveConsistentUnits

Bases: CoCo

This coco ensures that whenever an ODE function is defined, the physical unit of the left-hand side variable matches that of the right-hand side expression.

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_ode_functions_have_consistent_units.OdeFunctionConsistentUnitsVisitor

Bases: ASTVisitor

visit_ode_function(node)

Checks the coco. :param node: A single ode equation. :type node: ast_ode_equation

pynestml.cocos.co_co_odes_have_consistent_units module

class pynestml.cocos.co_co_odes_have_consistent_units.CoCoOdesHaveConsistentUnits

Bases: CoCo

This coco ensures that whenever an ODE is defined, the physical unit of the left-hand side variable matches that of the right-hand side expression.

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ast_neuron

class pynestml.cocos.co_co_odes_have_consistent_units.OdeConsistentUnitsVisitor

Bases: ASTVisitor

visit_ode_equation(node)

Checks the coco. :param node: A single ode equation. :type node: ast_ode_equation

pynestml.cocos.co_co_output_port_defined_if_emit_call module

class pynestml.cocos.co_co_output_port_defined_if_emit_call.CoCoOutputPortDefinedIfEmitCall

Bases: CoCo

This context condition checker ensures that if an event is emitted, a corresponding output port is defined with the appropriate type.

classmethod check_co_co(neuron: ASTNeuron)

Checks the coco for the handed over neuron. :param neuron: a single neuron instance.

class pynestml.cocos.co_co_output_port_defined_if_emit_call.OutputPortDefinedIfEmitCalledVisitor

Bases: ASTVisitor

This visitor ensures that all function calls are consistent.

neuron: ASTNeuron | None = None
visit_function_call(node: ASTFunctionCall)

If an emit_spike() function is found, check output block exists and has spike type.

Parameters:

node – a single function call.

pynestml.cocos.co_co_parameters_assigned_only_in_parameter_block module

class pynestml.cocos.co_co_parameters_assigned_only_in_parameter_block.CoCoParametersAssignedOnlyInParameterBlock

Bases: CoCo

This coco checks that no parameters are assigned outside the parameters block. Allowed:

parameters:

par mV = 10mV

Not allowed:
parameters:

par mV = 10mV

… update:

par = 20mV

classmethod check_co_co(node)

Ensures the coco for the handed over neuron. :param node: a single neuron instance. :type node: ASTNeuron

class pynestml.cocos.co_co_parameters_assigned_only_in_parameter_block.ParametersAssignmentVisitor

Bases: ASTVisitor

This visitor checks that no parameters have been assigned outside the parameters block.

visit_assignment(node: ASTAssignment) None

Checks the coco on the current node. :param node: a single node.

pynestml.cocos.co_co_priorities_correctly_specified module

class pynestml.cocos.co_co_priorities_correctly_specified.CoCoPrioritiesCorrectlySpecified

Bases: CoCo

This Coco ensures that priorities for event handlers are correctly specified.

classmethod check_co_co(node: ASTSynapse)

Checks the context condition. :param node: a single synapse

pynestml.cocos.co_co_resolution_func_legally_used module

class pynestml.cocos.co_co_resolution_func_legally_used.CoCoResolutionFuncLegallyUsed

Bases: CoCo

This Coco ensures that the predefined resolution() function appears only in the update, parameters, internals, or state block.

classmethod check_co_co(node)

Checks the coco. :param node: a single node (typically, a neuron or synapse)

class pynestml.cocos.co_co_resolution_func_legally_used.CoCoResolutionFuncLegallyUsedVisitor

Bases: ASTVisitor

visit_simple_expression(node)

Visits a single function call

Parameters:

node – a simple expression

pynestml.cocos.co_co_simple_delta_function module

class pynestml.cocos.co_co_simple_delta_function.CoCoSimpleDeltaFunction

Bases: CoCo

Check that predefined delta function is only used with single argument t.

classmethod check_co_co(node)

Checks if this coco applies for the handed over neuron.

Parameters:

node (ASTNeuron) – a single neuron instance.

pynestml.cocos.co_co_state_variables_initialized module

class pynestml.cocos.co_co_state_variables_initialized.CoCoStateVariablesInitialized

Bases: CoCo

This CoCo ensures that all the variables declared in the state block are initialized with a value.

classmethod check_co_co(node: ASTNeuron)

Checks if the coco applies for the node. All the variables declared in the state block must be initialized with a value. :param node:

pynestml.cocos.co_co_sum_has_correct_parameter module

class pynestml.cocos.co_co_sum_has_correct_parameter.CoCoSumHasCorrectParameter

Bases: CoCo

This coco ensures that convolve gets only simple variable references as inputs.

Not allowed:

V mV = convolve(g_in + g_ex, spikes_in)
classmethod check_co_co(neuron)

Ensures the coco for the handed over neuron. :param neuron: a single neuron instance. :type neuron: ASTNeuron

class pynestml.cocos.co_co_sum_has_correct_parameter.ConvolveParametersCorrectVisitor

Bases: ASTVisitor

visit_function_call(node)

Checks the coco on the current function call. :param node: a single function call. :type node: ASTFunctionCall

pynestml.cocos.co_co_user_defined_function_correctly_defined module

class pynestml.cocos.co_co_user_defined_function_correctly_defined.CoCoUserDefinedFunctionCorrectlyDefined

Bases: CoCo

This coco ensures that all user defined functions, which are defined with a type, have a return statement and the type of the return statement is consistent with the declaration. Allowed:

function foo(…) bool:

return True

Not allowed:
function foo(…) bool:

return

__processedFunction

A reference to the currently processed function.

Type:

ast_function

classmethod check_co_co(_node=None)

Checks the coco for the handed over node. :param _node: a single node instance. :type _node: ASTNeuron or ASTSynapse

processed_function = None

pynestml.cocos.co_co_v_comp_exists module

class pynestml.cocos.co_co_v_comp_exists.CoCoVCompDefined

Bases: CoCo

This class represents a constraint condition which ensures that variable v_comp has been defined if we have compartmental model case. When we start code generation with NEST_COMPARTMENTAL flag the following must exist:

state:

v_comp real = 0

classmethod check_co_co(neuron: ASTNeuron)

Checks if this coco applies for the handed over neuron. Models which are supposed to be compartmental but do not contain state variable called v_comp are not correct. :param neuron: a single neuron instance. :param after_ast_rewrite: indicates whether this coco is checked

after the code generator has done rewriting of the abstract syntax tree. If True, checks are not as rigorous. Use False where possible.

classmethod log_error(neuron: ASTNeuron, error_position, missing_variable_name)

pynestml.cocos.co_co_variable_once_per_scope module

class pynestml.cocos.co_co_variable_once_per_scope.CoCoVariableOncePerScope

Bases: CoCo

This coco ensures that each variables is defined at most once per scope, thus no redeclaration occurs.

classmethod check_co_co(node)

Checks if each variable is defined at most once per scope. Obviously, this test does not check if a declaration is shadowed by an embedded scope. :param node: a single neuron :type node: ast_neuron

pynestml.cocos.co_co_vector_declaration_right_size module

class pynestml.cocos.co_co_vector_declaration_right_size.CoCoVectorDeclarationRightSize

Bases: CoCo

This CoCo checks if the size of the vector during vector declaration is an integer and greater than 0, and that the index into a vector is of type integer and non-negative.

classmethod check_co_co(node: ASTNeuron)

This is an abstract method which should be implemented by all concrete cocos. :param node: a single neuron instance on which the coco will be checked. :type node: ast_neuron :return: True, if CoCo holds, otherwise False. :rtype: bool

class pynestml.cocos.co_co_vector_declaration_right_size.VectorDeclarationVisitor

Bases: ASTVisitor

This visitor checks if the size of the vector during vector declaration is an integer and greater than 0, and that the index into a vector is of type integer and non-negative.

visit_variable(node: ASTVariable)

Used to visit a single variable. :param node: a single variable. :type node: ASTVariable

pynestml.cocos.co_co_vector_input_port_correct_size_type module

class pynestml.cocos.co_co_vector_input_port_correct_size_type.CoCoVectorInputPortsCorrectSizeType

Bases: CoCo

This CoCo checks if the size of the vector input port is of the type integer and its value is greater than 0.

classmethod check_co_co(node: ASTNeuron)

This is an abstract method which should be implemented by all concrete cocos. :param node: a single neuron instance on which the coco will be checked. :type node: ast_neuron :return: True, if CoCo holds, otherwise False. :rtype: bool

class pynestml.cocos.co_co_vector_input_port_correct_size_type.InputPortsVisitor

Bases: ASTVisitor

This visitor checks if the size of the vector input port is of the type integer and its value is greater than 0

visit_input_port(node: ASTInputPort)

Used to visit a single input port. :param node: a single input port. :type node: ASTInputPort

pynestml.cocos.co_co_vector_parameter_declared_in_right_block module

class pynestml.cocos.co_co_vector_parameter_declared_in_right_block.CoCoVectorParameterDeclaredInRightBlock

Bases: CoCo

This CoCo ensures that the vector parameter is declared in either the parameters or internals block.

classmethod check_co_co(node: ASTNeuron)

This is an abstract method which should be implemented by all concrete cocos. :param node: a single neuron instance on which the coco will be checked. :type node: ast_neuron :return: True, if CoCo holds, otherwise False. :rtype: bool

class pynestml.cocos.co_co_vector_parameter_declared_in_right_block.VectorDeclarationVisitor

Bases: ASTVisitor

This visitor ensures that the vector parameter is declared in the right block and has an integer type.

visit_declaration(node: ASTDeclaration)

Used to visit a single declaration. :param node: a declaration object. :type node: ASTDeclaration

pynestml.cocos.co_co_vector_variable_in_non_vector_declaration module

class pynestml.cocos.co_co_vector_variable_in_non_vector_declaration.CoCoVectorVariableInNonVectorDeclaration

Bases: CoCo

This coco ensures that vector variables are not used in non vector declarations. Not allowed:

function three integer[n] = 3 threePlusFour integer = three + 4 <- error: threePlusFour is not a vector

classmethod check_co_co(node)

Ensures the coco for the handed over node. :param node: a single node instance. :type node: ASTNeuron or ASTSynapse

class pynestml.cocos.co_co_vector_variable_in_non_vector_declaration.VectorInDeclarationVisitor

Bases: ASTVisitor

This visitor checks if somewhere in a declaration of a non-vector value, a vector is used.

visit_declaration(node)

Checks the coco. :param node: a single declaration. :type node: ast_declaration

pynestml.cocos.co_cos_manager module

class pynestml.cocos.co_cos_manager.CoCosManager

Bases: object

This class provides a set of context conditions which have to hold for each neuron instance.

classmethod check_co_co_priorities_correctly_specified(neuron: ASTNeuron)
Parameters:

neuron – a single neuron object.

classmethod check_compartmental_model(neuron: ASTNeuron) None

collects all relevant information for the different compartmental mechanism classes for later code-generation

searches for inlines or odes with decorator @mechanism::<type> and performs a base and, depending on type, specific information collection process. See nestml documentation on compartmental code generation.

classmethod check_convolve_cond_curr_is_correct(neuron: ASTNeuron)

Checks if all convolve rhs are correctly provided with arguments. :param neuron: a single neuron object.

classmethod check_correct_usage_of_kernels(neuron: ASTNeuron)

Checks if all kernels are only used in convolve. :param neuron: a single neuron object.

classmethod check_each_block_defined_at_most_once(node: ASTNeuron | ASTSynapse)

Checks if in the handed over neuron or synapse, each block is defined at most once and mandatory blocks are defined. :param node: a single neuron or synapse instance

classmethod check_expression_correct(neuron: ASTNeuron)

Checks that all rhs in the model are correctly constructed, e.g. type(lhs)==type(rhs). :param neuron: a single neuron

classmethod check_function_argument_template_types_consistent(neuron: ASTNeuron)

Checks if no declaration a vector value is added to a non vector one. :param neuron: a single neuron object.

classmethod check_function_declared_and_correctly_typed(neuron: ASTNeuron)

Checks if in the handed over neuron all function calls use existing functions and the arguments are correctly typed. :param neuron: a single neuron instance

classmethod check_function_defined(neuron: ASTNeuron)

Checks for the handed over neuron that each used function it is defined.

classmethod check_initial_ode_initial_values(neuron: ASTNeuron)

Checks if variables of odes are declared in the state block. :param neuron: a single neuron object.

classmethod check_inline_expression_not_assigned_to(neuron: ASTNeuron)

Checks for the handed over neuron that inline expressions are not assigned to.

classmethod check_inline_expressions_have_rhs(neuron: ASTNeuron)

Checks that all inline expressions have a right-hand side. :param neuron: a single neuron object

classmethod check_inline_has_max_one_lhs(neuron: ASTNeuron)

Checks that all inline expressions have exactly one left-hand side. :param neuron: a single neuron object.

classmethod check_input_port_qualifier_unique(neuron: ASTNeuron)

Checks that no spiking input ports are defined with redundant qualifiers. :param neuron: a single neuron object.

classmethod check_input_port_size_type(neuron: ASTNeuron)
Parameters:

neuron – a single neuron object

classmethod check_input_ports_not_assigned_to(neuron: ASTNeuron)

Checks that no values are assigned to input ports. :param neuron: a single neuron object.

classmethod check_integrate_odes_called_if_equations_defined(neuron: ASTNeuron)

Ensures that integrate_odes() is called if one or more dynamical equations are defined.

classmethod check_internals_not_assigned_outside_internals_block(neuron: ASTNeuron)

Checks that internals are not assigned outside the internals block. :param neuron: a single neuron object.

classmethod check_invariant_type_correct(neuron: ASTNeuron)

Checks if all invariants are of type boolean. :param neuron: a single neuron object.

classmethod check_kernel_type(neuron: ASTNeuron) None

Checks that all defined kernels have type real.

classmethod check_neuron_names_unique(compilation_unit)

Checks that all declared neurons in a compilation unit have a unique name. :param compilation_unit: a single compilation unit. :type compilation_unit: ASTCompilationUnit

classmethod check_no_duplicate_compilation_unit_names(compilation_units)

Checks if in a set of compilation units, two nodes have the same name. :param compilation_units: a list of compilation units :type compilation_units: list(ASTNestMLCompilationUnit)

classmethod check_no_nest_namespace_collisions(neuron: ASTNeuron)

Checks that all units which have a numeric numerator use 1. :param neuron: a single neuron object.

classmethod check_numerator_of_unit_is_one_if_numeric(neuron: ASTNeuron)

Checks that all units which have a numeric numerator use 1. :param neuron: a single neuron object.

classmethod check_ode_functions_have_consistent_units(neuron: ASTNeuron)

Checks that all ODE function lhs and rhs have consistent units. :param neuron: a single neuron object.

classmethod check_odes_have_consistent_units(neuron: ASTNeuron)

Checks that all ODE lhs and rhs have consistent units. :param neuron: a single neuron object.

classmethod check_order_of_equations_correct(neuron: ASTNeuron)

Checks that all equations specify the order of the variable. :param neuron: a single neuron object.

classmethod check_output_port_defined_if_emit_call(neuron: ASTNeuron)

Checks that if emit_spike() function is called, an spiking output port is defined. :param neuron: a single neuron object. :type neuron: ASTNeuron

classmethod check_parameters_not_assigned_outside_parameters_block(neuron: ASTNeuron)

Checks that parameters are not assigned outside the parameters block. :param neuron: a single neuron object.

classmethod check_resolution_func_legally_used(neuron: ASTNeuron)
Parameters:

neuron – a single neuron object.

classmethod check_simple_delta_function(neuron: ASTNeuron) None
classmethod check_state_variables_initialized(neuron: ASTNeuron)

Checks if all the variables declared in state block are initialized with a value :param neuron: a single neuron instance

classmethod check_sum_has_correct_parameter(neuron: ASTNeuron)

Checks that all convolve function calls have variables as arguments. :param neuron: a single neuron object.

classmethod check_user_defined_function_correctly_built(neuron: ASTNeuron)

Checks that all user defined functions are correctly constructed, i.e., have a return statement if declared and that the type corresponds to the declared one. :param neuron: a single neuron object.

classmethod check_v_comp_requirement(neuron: ASTNeuron)

In compartmental case, checks if v_comp variable was defined :param neuron: a single neuron object

classmethod check_variables_defined_before_usage(neuron: ASTNeuron, after_ast_rewrite: bool) None

Checks that all variables are defined before being used. :param neuron: a single neuron.

classmethod check_variables_unique_in_scope(neuron: ASTNeuron)

Checks that all variables have been declared at most once per scope. :param neuron: a single neuron instance

classmethod check_vector_declaration_size(neuron: ASTNeuron)

Checks if the vector is declared with a size greater than 0 :param neuron: a single neuron object

classmethod check_vector_in_non_vector_declaration_detected(neuron: ASTNeuron)

Checks if no declaration a vector value is added to a non vector one. :param neuron: a single neuron object.

classmethod check_vector_parameter_declaration(neuron: ASTNeuron)

Checks if the vector parameter is declared in the right block :param neuron: a single neuron object

classmethod post_symbol_table_builder_checks(neuron: ASTNeuron, after_ast_rewrite: bool = False)

Checks all context conditions. :param neuron: a single neuron object.