pynestml.cocos package
Submodules
pynestml.cocos.co_co module
- class pynestml.cocos.co_co.CoCo
Bases:
objectThis class represents an abstract super-class for all concrete context conditions to check. All context condition checks inherit from this class.
CoCos do not return values or raise exceptions; in case of issues, they messages are logged at the appropriate level.
- abstract classmethod check_co_co(node: ASTNode)
Check the coco.
- Parameters:
node – a single ASTNode instance on which the coco will be checked.
- 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:
CoCoThis 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
pynestml.cocos.co_co_cm_channel_model module
pynestml.cocos.co_co_cm_concentration_model module
pynestml.cocos.co_co_cm_continuous_input_model module
pynestml.cocos.co_co_cm_synapse_model module
pynestml.cocos.co_co_convolve_cond_correctly_built module
- class pynestml.cocos.co_co_convolve_cond_correctly_built.CoCoConvolveCondCorrectlyBuilt
Bases:
CoCoThis coco ensures that
convolveis 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 )
- class pynestml.cocos.co_co_convolve_cond_correctly_built.ConvolveCheckerVisitor
Bases:
ASTVisitorVisits 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_convolve_has_correct_parameter module
- class pynestml.cocos.co_co_convolve_has_correct_parameter.CoCoConvolveHasCorrectParameter
Bases:
CoCoThis 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(model)
Ensures the coco for the handed over model. :param model: a single model instance.
=
- class pynestml.cocos.co_co_convolve_has_correct_parameter.ConvolveParametersCorrectVisitor
Bases:
ASTVisitor- visit_function_call(node: ASTFunctionCall)
Checks the coco on the current function call. :param node: a single function call.
pynestml.cocos.co_co_correct_numerator_of_unit module
- class pynestml.cocos.co_co_correct_numerator_of_unit.CoCoCorrectNumeratorOfUnit
Bases:
CoCoThis 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 = …
- class pynestml.cocos.co_co_correct_numerator_of_unit.NumericNumeratorVisitor
Bases:
ASTVisitorVisits 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:
CoCoThis 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 = …
- class pynestml.cocos.co_co_correct_order_in_equation.OrderOfEquationVisitor
Bases:
ASTVisitorThis 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
pynestml.cocos.co_co_emit_spike_function_arguments module
- class pynestml.cocos.co_co_emit_spike_function_arguments.CoCoEmitSpikeFunctionArguments
Bases:
CoCoThis context condition checker ensures that all calls to the
emit_spike()function contain zero or one parameter.
- class pynestml.cocos.co_co_emit_spike_function_arguments.EmitSpikeFunctionArgumentsVisitor
Bases:
ASTVisitor- 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_equations_only_for_init_values module
- class pynestml.cocos.co_co_equations_only_for_init_values.CoCoEquationsOnlyForInitValues
Bases:
CoCoThis coco ensures that ode equations are only provided for variables which have been defined in the state block. Allowed:
Not allowed:
- class pynestml.cocos.co_co_equations_only_for_init_values.EquationsOnlyForInitValues
Bases:
ASTVisitorThis 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:
CoCoThis 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: ASTModel
- class pynestml.cocos.co_co_function_argument_template_types_consistent.CorrectTemplatedArgumentTypesVisitor
Bases:
ASTVisitorThis 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:
CoCoThis 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: ASTModel
- class pynestml.cocos.co_co_function_calls_consistent.FunctionCallConsistencyVisitor
Bases:
ASTVisitorThis 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
pynestml.cocos.co_co_illegal_expression module
- class pynestml.cocos.co_co_illegal_expression.CoCoIllegalExpression
Bases:
CoCoThis 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: ASTModel
- class pynestml.cocos.co_co_illegal_expression.CorrectExpressionVisitor
Bases:
ASTVisitorThis 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:
CoCoThis coco ensures that no values are assigned to inline expressions.
- 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:
CoCoThis coco ensures that all inline expressions have a rhs.
- class pynestml.cocos.co_co_inline_expressions_have_rhs.InlineRhsVisitor
Bases:
ASTVisitorThis 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:
CoCoThis 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
- class pynestml.cocos.co_co_inline_max_one_lhs.InlineMaxOneLhs
Bases:
ASTVisitorThis 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:
CoCoThis 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
- 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_integrate_odes_called_if_equations_defined module
- class pynestml.cocos.co_co_integrate_odes_called_if_equations_defined.CoCoIntegrateOdesCalledIfEquationsDefined
Bases:
CoCoThis coco ensures that integrate_odes() is called if one or more dynamical equations are defined.
- class pynestml.cocos.co_co_integrate_odes_called_if_equations_defined.EquationsDefinedVisitor
Bases:
ASTVisitorThis visitor checks if equations are defined.
- 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:
ASTVisitorThis visitor checks if integrate_odes() is called.
- 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_integrate_odes_params_correct module
- class pynestml.cocos.co_co_integrate_odes_params_correct.CoCoIntegrateODEsParamsCorrect
Bases:
CoCoThis coco ensures that
integrate_odes()contains either no parameters or only state variable names as parameters.
- class pynestml.cocos.co_co_integrate_odes_params_correct.IntegrateODEsCheckerVisitor
Bases:
ASTVisitor- 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_internals_assigned_only_in_internals_block module
- class pynestml.cocos.co_co_internals_assigned_only_in_internals_block.CoCoInternalsAssignedOnlyInInternalsBlock
Bases:
CoCoThis coco checks that no internals are assigned outside the internals block.
- class pynestml.cocos.co_co_internals_assigned_only_in_internals_block.InternalsAssignmentVisitor
Bases:
ASTVisitorThis 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:
CoCoThis coco checks that all invariants are of type boolean
- class pynestml.cocos.co_co_invariant_is_boolean.InvariantTypeVisitor
Bases:
ASTVisitorChecks 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:
CoCoEnsures 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'' = ...).
- class pynestml.cocos.co_co_kernel_type.KernelTypeVisitor
Bases:
ASTVisitorThis 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_model_name_unique module
- class pynestml.cocos.co_co_model_name_unique.CoCoModelNameUnique
Bases:
CoCoThis coco ensures that for all elements in a single compile units, the names of all models are pairwise distinct. Allowed:
- model a:
…
… model b:
…
- Not allowed:
- model a:
…
… model a: <- model 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_nest_random_functions_legally_used module
- class pynestml.cocos.co_co_nest_random_functions_legally_used.CoCoNestRandomFunctionsLegallyUsed
Bases:
CoCoThis CoCo ensure that the random functions are used only in the
update,onReceive, andonConditionblocks. This CoCo is only checked for the NEST Simulator target.
- class pynestml.cocos.co_co_nest_random_functions_legally_used.CoCoNestRandomFunctionsLegallyUsedVisitor
Bases:
ASTVisitor- visit_function_call(node)
Visits a function call :param node: a function call
pynestml.cocos.co_co_nest_synapse_delay_not_assigned_to module
- class pynestml.cocos.co_co_nest_synapse_delay_not_assigned_to.CoCoNESTSynapseDelayNotAssignedTo
Bases:
CoCoThis coco checks that the delay variable or parameter is not assigned to inside of a NESTML model. (This could be possible in general, but is not supported for now.)
- class pynestml.cocos.co_co_nest_synapse_delay_not_assigned_to.CoCoNESTSynapseDelayNotAssignedToVisitor
Bases:
ASTVisitor- visit_assignment(node: ASTAssignment) None
Checks the coco on the current node. :param node: a single node.
pynestml.cocos.co_co_no_duplicate_compilation_unit_names module
- class pynestml.cocos.co_co_no_duplicate_compilation_unit_names.CoCoNoDuplicateCompilationUnitNames
Bases:
CoCoThis 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:
CoCoThis 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 )
- class pynestml.cocos.co_co_no_kernels_except_in_convolve.KernelCollectingVisitor
Bases:
ASTVisitor- collect_kernels(model: ASTModel) List[str]
Collects all kernels in the model. :param neuron: a single model instance :return: a list of kernels.
- 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: ASTModel)
Ensures the coco for the handed over neuron. :param node: a single neuron instance.
- 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:
CoCoThis 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.
- 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:
CoCoThis 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.
- 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_on_receive_vectors_should_be_constant_size module
- class pynestml.cocos.co_co_on_receive_vectors_should_be_constant_size.CoCoOnReceiveVectorsShouldBeConstantSize
Bases:
CoCoThis CoCo is used to test the usage of onReceive blocks for vector ports of variable length.
- class pynestml.cocos.co_co_on_receive_vectors_should_be_constant_size.CoCoOnReceiveVectorsShouldBeConstantSizeVisitor
Bases:
ASTVisitor- 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_output_port_defined_if_emit_call module
- class pynestml.cocos.co_co_output_port_defined_if_emit_call.CoCoOutputPortDefinedIfEmitCall
Bases:
CoCoThis context condition checker ensures that if an event is emitted, a corresponding output port is defined with the appropriate type.
- class pynestml.cocos.co_co_output_port_defined_if_emit_call.OutputPortDefinedIfEmitCalledVisitor
Bases:
ASTVisitorThis visitor ensures that all function calls are consistent.
- 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:
CoCoThis 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: ASTModel
- class pynestml.cocos.co_co_parameters_assigned_only_in_parameter_block.ParametersAssignmentVisitor
Bases:
ASTVisitorThis 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
pynestml.cocos.co_co_resolution_func_legally_used module
- class pynestml.cocos.co_co_resolution_func_legally_used.CoCoResolutionFuncLegallyUsed
Bases:
CoCoThis 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_resolution_func_used module
pynestml.cocos.co_co_simple_delta_function module
pynestml.cocos.co_co_spike_input_ports_appear_only_in_equation_rhs_and_event_handlers module
- class pynestml.cocos.co_co_spike_input_ports_appear_only_in_equation_rhs_and_event_handlers.CoCoSpikeInputPortsAppearOnlyInEquationRHSAndEventHandlers
Bases:
CoCoThis coco ensures that spiking input port names appear only in the right-hand side of equations and in the onReceive block declaration.
- classmethod check_co_co(node)
Ensures the coco for the handed over node.
- class pynestml.cocos.co_co_spike_input_ports_appear_only_in_equation_rhs_and_event_handlers.SpikeInputPortsAppearOnlyInEquationRHSAndEventHandlersVisitor
Bases:
ASTVisitor- visit_variable(node: ASTVariable)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
pynestml.cocos.co_co_state_variables_initialized module
pynestml.cocos.co_co_timestep_function_legally_used module
- class pynestml.cocos.co_co_timestep_function_legally_used.CoCoTimestepFuncLegallyUsed
Bases:
CoCoThis Coco ensures that the predefined
timestep()function appears only in the update.- classmethod check_co_co(node)
Checks the coco. :param node: a single node (typically, a neuron or synapse)
- class pynestml.cocos.co_co_timestep_function_legally_used.CoCoTimestepFuncLegallyUsedVisitor
Bases:
ASTVisitor- visit_simple_expression(node)
Visits a single function call
- Parameters:
node – a simple expression
pynestml.cocos.co_co_user_defined_function_correctly_defined module
- class pynestml.cocos.co_co_user_defined_function_correctly_defined.CoCoUserDefinedFunctionCorrectlyDefined
Bases:
CoCoThis 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: ASTModel
- processed_function = None
pynestml.cocos.co_co_v_comp_exists module
- class pynestml.cocos.co_co_v_comp_exists.CoCoVCompDefined
Bases:
CoCoThis 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
pynestml.cocos.co_co_variable_once_per_scope module
pynestml.cocos.co_co_vector_declaration_right_size module
- class pynestml.cocos.co_co_vector_declaration_right_size.CoCoVectorDeclarationRightSize
Bases:
CoCoThis 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.
- class pynestml.cocos.co_co_vector_declaration_right_size.VectorDeclarationVisitor
Bases:
ASTVisitorThis 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:
CoCoThis CoCo checks if the size of the vector input port is of the type integer and its value is greater than 0.
- class pynestml.cocos.co_co_vector_input_port_correct_size_type.InputPortsVisitor
Bases:
ASTVisitorThis 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:
CoCoThis CoCo ensures that the vector parameter is declared in either the parameters or internals block.
- class pynestml.cocos.co_co_vector_parameter_declared_in_right_block.VectorDeclarationVisitor
Bases:
ASTVisitorThis 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:
CoCoThis 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: ASTModel
- class pynestml.cocos.co_co_vector_variable_in_non_vector_declaration.VectorInDeclarationVisitor
Bases:
ASTVisitorThis 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:
objectThis class provides a set of context conditions which have to hold for each model instance.
- classmethod check_co_co_emit_spike_function_arguments(model: ASTModel)
Checks that all calls to the
emit_spike()function contain zero or one parameter. :param model: a single model object.
- classmethod check_co_co_nest_random_functions_legally_used(model: ASTModel)
Checks if the random number functions are used only in the update block. :param model: a single model object.
- classmethod check_co_co_priorities_correctly_specified(model: ASTModel)
- Parameters:
model – a single model object.
- classmethod check_cocos(model: ASTModel, after_ast_rewrite: bool = False)
Checks all context conditions. :param model: a single model object.
- classmethod check_compartmental_model(neuron: ASTModel) 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(model: ASTModel)
Checks if all convolve rhs are correctly provided with arguments. :param model: a single model object.
- classmethod check_convolve_has_correct_parameter(model: ASTModel)
Checks that all convolve function calls have variables as arguments. :param model: a single model object.
- classmethod check_correct_usage_of_kernels(model: ASTModel)
Checks if all kernels are only used in convolve. :param model: a single model object.
- classmethod check_each_block_defined_at_most_once(node: ASTModel)
Checks if in the handed over model, each block is defined at most once and mandatory blocks are defined. :param node: a single model instance
- classmethod check_expression_correct(model: ASTModel)
Checks that all rhs in the model are correctly constructed, e.g. type(lhs)==type(rhs). :param model: a single model
- classmethod check_function_argument_template_types_consistent(model: ASTModel)
Checks if no declaration a vector value is added to a non vector one. :param model: a single model object.
- classmethod check_function_declared_and_correctly_typed(model: ASTModel)
Checks if in the handed over model all function calls use existing functions and the arguments are correctly typed. :param model: a single model instance
- classmethod check_function_defined(model: ASTModel)
Checks for the handed over model that each used function it is defined.
- classmethod check_initial_ode_initial_values(model: ASTModel)
Checks if variables of odes are declared in the state block. :param model: a single model object.
- classmethod check_inline_expression_not_assigned_to(model: ASTModel)
Checks for the handed over model that inline expressions are not assigned to.
- classmethod check_inline_expressions_have_rhs(model: ASTModel)
Checks that all inline expressions have a right-hand side. :param model: a single model object
- classmethod check_inline_has_max_one_lhs(model: ASTModel)
Checks that all inline expressions have exactly one left-hand side. :param model: a single model object.
- classmethod check_input_ports_appear_only_in_equation_rhs_and_event_handlers(node: ASTModel)
Checks if in the handed over model, each block is defined at most once and mandatory blocks are defined. :param node: a single model instance
- classmethod check_input_ports_not_assigned_to(model: ASTModel)
Checks that no values are assigned to input ports. :param model: a single model object.
- classmethod check_integrate_odes_called_if_equations_defined(model: ASTModel)
Ensures that integrate_odes() is called if one or more dynamical equations are defined.
- classmethod check_integrate_odes_params_correct(model: ASTModel)
Checks if all integrate_odes() calls have correct parameters. :param model: a single model object.
- classmethod check_internals_not_assigned_outside_internals_block(model: ASTModel)
Checks that internals are not assigned outside the internals block. :param model: a single model object.
- classmethod check_invariant_type_correct(model: ASTModel)
Checks if all invariants are of type boolean. :param model: a single model object.
- classmethod check_kernel_type(model: ASTModel) None
Checks that all defined kernels have type real.
- classmethod check_model_names_unique(compilation_unit)
Checks that all declared models 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(model: ASTModel)
Checks that all units which have a numeric numerator use 1. :param model: a single model object.
- classmethod check_numerator_of_unit_is_one_if_numeric(model: ASTModel)
Checks that all units which have a numeric numerator use 1. :param model: a single model object.
- classmethod check_ode_functions_have_consistent_units(model: ASTModel)
Checks that all ODE function lhs and rhs have consistent units. :param model: a single model object.
- classmethod check_odes_have_consistent_units(model: ASTModel)
Checks that all ODE lhs and rhs have consistent units. :param model: a single model object.
- classmethod check_on_receive_vectors_should_be_constant_size(model: ASTModel)
- Parameters:
model – a single model object
- classmethod check_order_of_equations_correct(model: ASTModel)
Checks that all equations specify the order of the variable. :param model: a single model object.
- classmethod check_output_port_defined_if_emit_call(model: ASTModel)
Checks that if emit_spike() function is called, an spiking output port is defined. :param model: a single model object.
- classmethod check_parameters_not_assigned_outside_parameters_block(model: ASTModel)
Checks that parameters are not assigned outside the parameters block. :param model: a single model object.
- classmethod check_resolution_func_legally_used(model: ASTModel)
- Parameters:
model – a single model object.
- classmethod check_resolution_func_used(model: ASTModel)
Checks if all invariants are of type boolean. :param model: a single model object.
- classmethod check_state_variables_initialized(model: ASTModel)
Checks if all the variables declared in state block are initialized with a value :param model: a single model instance
- classmethod check_timestep_func_legally_used(model: ASTModel)
- Parameters:
model – a single model object.
- classmethod check_user_defined_function_correctly_built(model: ASTModel)
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 model: a single model object.
- classmethod check_v_comp_requirement(neuron: ASTModel)
In compartmental case, checks if v_comp variable was defined :param neuron: a single neuron object
- classmethod check_variables_defined_before_usage(model: ASTModel) None
Checks that all variables are defined before being used. :param model: a single model.
- classmethod check_variables_unique_in_scope(model: ASTModel)
Checks that all variables have been declared at most once per scope. :param model: a single model instance
- classmethod check_vector_declaration_size(model: ASTModel)
Checks if the vector is declared with a size greater than 0 :param model: a single model object