pynestml.utils package

Submodules

pynestml.utils.ast_nestml_printer module

pynestml.utils.ast_source_location module

class pynestml.utils.ast_source_location.ASTSourceLocation(start_line, start_column, end_line, end_column)

Bases: object

This 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

bool

equals(source_position)

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. :rtype: bool

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_utils module

pynestml.utils.cloning_helpers module

pynestml.utils.either module

class pynestml.utils.either.Either(value=None, error=None)

Bases: object

Objects of these class are either values or error messages. .. attribute:: __value

The value.

type

object

__error

An error message.

Type

str

classmethod error(error)

Construct an Either holding an error message :param error: an error message :type error: str :return: an Either object holding an error message :rtype: Either

get_error()

Get the error message saved in the Either object :return: an error message :rtype: str

get_value()

Get the valid value saved in the Either object :return: valid value :rtype: any type of valid values

is_error()

Return whether the object holds an error message :return: true iff the object holds an error message :rtype: bool

is_value()

Return whether the object holds a valid value :return: true iff object holds a valid value :rtype: bool

classmethod value(value)

Construct an Either holding a valid value :param value: the value to hold :type: _value: anything :return: an Either object holding a valid value :rtype: Either

pynestml.utils.error_listener module

pynestml.utils.error_strings module

class pynestml.utils.error_strings.ErrorStrings

Bases: object

These error strings are part of the type calculation system and are kept separated from the message class for the sake of a clear and direct maintenance of type system as an individual component.

SEPARATOR = ' : '
classmethod code(_origin=None)

Helper method returning a unique identifier for the various classes that produce and log error messages :param _origin: the class reporting an error :return: identifier unique to that class :rtype: str

classmethod message_add_sub_type_mismatch(origin, lhs_type_text, rhs_type_text, result_type_text, source_position)

construct an message indicating that the types of an addition/subtraction are not compatible and that the result is implicitly cast to a different type :param origin: the class reporting the error :param lhs_type_text: plain text of Lhs type :type lhs_type_text: str :param rhs_type_text: plain text of Rhs type :type rhs_type_text: str :param result_type_text: plain text of resulting type (implicit cast) :type result_type_text: str :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_cannot_calculate_convolve_type(origin, source_position)

construct an error message indicating that the type of a convolve() call is ill-defined :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_comparison(origin, source_position)

construct an error message indicating that an a comparison operation has incompatible operands :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_expected_bool(origin, source_position)

construct an error message indicating that an expected bool value was not found :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_expected_int(origin, source_position)

construct an error message indicating that an expected int value was not found :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_implicit_magnitude_conversion(origin, parent_node)

Construct an warning for implicit conversion from parent_node.rhs to parent_node.lhs :param origin: the class dropping the warning :param parent_node: the addition,subtraction or assignment that requires implicit conversion :type: an ASTExpression that is either an Addition or a Subtraction for which an implicit conversion has already been determined :return: the warning message

classmethod message_logic_operands_not_bool(origin, source_position)

construct an error message indicating that an a comparison operation has incompatible operands :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_no_semantics(origin, expr_text, source_position)

construct an error message indicating that an rhs is not implemented :param origin: the class reporting the error :param expr_text: plain text of the unimplemented rhs :type expr_text: str :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_non_constant_exponent(origin, source_position)

construct an error message indicating that the exponent given to a unit base is not a constant value :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_non_numeric_type(origin, type_name, source_position)

construct an error message indicating an expected numeric type is not, in fact, numeric :param origin: the class reporting the error :param type_name: plain text representation of the wrong type that was encountered :type type_name: str :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_resolve_fail(origin, symbol_name, source_position)

construct an error message indicating that a symbol could not be resolved :param origin: the class reporting the error :param symbol_name: the name of the symbol :type symbol_name: str :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_ternary(origin, source_position)

construct an error message indicating that an a comparison operation has incompatible operands :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_ternary_mismatch(origin, if_true_text, if_not_text, source_position)

construct an error message indicating that an a comparison operation has incompatible operands :param origin: the class reporting the error :param if_true_text: plain text of the positive branch of the ternary operator :type if_true_text: str :param if_not_text: plain text of the negative branch of the ternary operator :type if_not_text: str :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_type_error(origin, expression_text, source_position)

construct an error message indicating a generic error in rhs type calculation :param origin: the class reporting the error :param expression_text: plain text representation of the offending rhs :type expression_text: str :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_unit_base(origin, source_position)

construct an error message indicating that a non-int type was given as exponent to a unit type :param origin: the class reporting the error :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

classmethod message_void_function_on_rhs(origin, function_name, source_position)

construct an error message indicating that a void function cannot be used on a RHS :param origin: the class reporting the error :param function_name: the offending function :type function_name: str :param source_position: The location where the error was encountered :type source_position: ASTSourceLocation :return: the error message :rtype: str

pynestml.utils.logger module

class pynestml.utils.logger.Logger

Bases: object

This 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. Map from id
Type

int

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_all_messages_of_level(level: pynestml.utils.logger.LoggingLevel) List[Tuple[pynestml.meta_model.ast_node.ASTNode, pynestml.utils.logger.LoggingLevel, str]]

Returns all messages which have a certain logging level. :param level: a logging level :type level: LoggingLevel :return: a list of messages with their levels. :rtype: list((str,Logging_Level)

classmethod get_all_messages_of_level_and_or_node(node: pynestml.meta_model.ast_node.ASTNode, level: pynestml.utils.logger.LoggingLevel) List[Tuple[pynestml.meta_model.ast_node.ASTNode, pynestml.utils.logger.LoggingLevel, str]]

Returns all messages which have a certain logging level, or have been reported for a certain node, or both. :param node: a single node instance :param level: a logging level :type level: LoggingLevel :return: a list of messages with their levels. :rtype: list((str,Logging_Level)

classmethod get_all_messages_of_node(node: pynestml.meta_model.ast_node.ASTNode) List[Tuple[pynestml.meta_model.ast_node.ASTNode, pynestml.utils.logger.LoggingLevel, str]]

Returns all messages which have been reported for a certain node. :param node: a single node instance :return: a list of messages with their levels. :rtype: list((str,Logging_Level)

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[pynestml.meta_model.ast_node.ASTNode, pynestml.utils.logger.LoggingLevel, str]]

Returns the overall log of messages. The structure of the log is: (NODE, LEVEL, MESSAGE) :return: mapping from id to ASTNode, log level and message.

classmethod has_errors(node: pynestml.meta_model.ast_node.ASTNode) bool

Indicates whether the handed over node, thus the corresponding model, has errors. :param node: a single node instance. :return: True if errors detected, otherwise False :rtype: bool

classmethod init_logger(logging_level: pynestml.utils.logger.LoggingLevel)

Initializes the logger. :param logging_level: the logging level as required :type logging_level: LoggingLevel

classmethod level_to_string(level: pynestml.utils.logger.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: Optional[pynestml.meta_model.ast_node.ASTNode] = None, code: Optional[pynestml.utils.messages.MessageCode] = None, message: Optional[str] = None, error_position: Optional[pynestml.utils.ast_source_location.ASTSourceLocation] = None, log_level: Optional[pynestml.utils.logger.LoggingLevel] = None)

Logs the handed over message on the handed over node. If the current logging is appropriate, the message is also printed. :param node: the node in which the error occurred :param code: a single error code :type code: ErrorCode :param error_position: the position on which the error occurred. :type error_position: SourcePosition :param message: a message. :type message: str :param log_level: the corresponding log level. :type log_level: LoggingLevel

logging_level = None
no_print = False
classmethod set_current_node(node: Optional[pynestml.meta_model.ast_node.ASTNode]) None

Sets the handed over node as the currently processed one. This enables a retrieval of messages for a specific node. :param node: a single node instance

classmethod set_log(log, counter)

Restores log from the ‘log’ variable :param log: the log :param counter: the counter

classmethod set_logging_level(level: pynestml.utils.logger.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) pynestml.utils.logger.LoggingLevel

Returns the logging level corresponding to the handed over string. If no such exits, returns None. :param string: a single string representing the level. :type string: str :return: a single logging level. :rtype: LoggingLevel

class pynestml.utils.logger.LoggingLevel(value)

Bases: enum.Enum

Different types of logging levels, this part can be extended.

DEBUG = 0
ERROR = 3
INFO = 1
NO = 4
WARNING = 2

pynestml.utils.logging_helper module

expression : left=expression (plusOp=’+’ | minusOp=’-’) right=expression

class pynestml.utils.logging_helper.LoggingHelper

Bases: object

static drop_missing_type_error(_assignment)

pynestml.utils.messages module

class pynestml.utils.messages.MessageCode(value)

Bases: enum.Enum

A mapping between codes and the corresponding messages.

ADD_SUB_TYPE_MISMATCH = 7
ANALYSING_TRANSFORMING_NEURON = 64
ARG_NOT_KERNEL_OR_EQUATION = 20
ARG_NOT_SPIKE_INPUT = 21
ASTDATATYPE_TYPE_SYMBOL_COULD_NOT_BE_DERIVED = 72
BLOCK_NOT_CORRECT = 25
BUFFER_SET_TO_CONDUCTANCE_BASED = 8
CAST_NOT_POSSIBLE = 5
CODE_SUCCESSFULLY_GENERATED = 14
CONTINUOUS_INPUT_PORT_WITH_QUALIFIERS = 24
CONVOLVE_NEEDS_BUFFER_PARAMETER = 58
DELTA_FUNCTION_CANNOT_BE_MIXED = 70
EMIT_SPIKE_FUNCTION_BUT_NO_OUTPUT_PORT = 75
EQUATIONS_DEFINED_BUT_INTEGRATE_ODES_NOT_CALLED = 78
FUNCTION_CALL_TYPE_ERROR = 2
FUNCTION_NOT_DECLARED = 31
FUNCTION_REDECLARED = 30
HARD_INCOMPATIBILITY = 46
IMPLICIT_CAST = 4
INPUT_PATH_NOT_FOUND = 59
INTERNAL_WARNING = 56
KERNEL_IV_WRONG_TYPE = 74
KERNEL_OUTSIDE_CONVOLVE = 36
KERNEL_WRONG_TYPE = 73
LEXER_ERROR = 60
MODEL_CONTAINS_ERRORS = 12
MODEL_REDECLARED = 34
MODULE_NAME_INFO = 67
MODULE_SUCCESSFULLY_GENERATED = 15
MULTIPLE_KEYWORDS = 42
NAME_COLLISION = 37
NEST_COLLISION = 35
NEURON_ANALYZED = 53
NEURON_SOLVED_BY_GSL = 52
NOT_A_VARIABLE = 41
NOT_LAST_STATEMENT = 48
NOT_NEUROSCIENCE_UNIT = 55
NO_ASSIGNMENT_ALLOWED = 40
NO_CODE_GENERATED = 16
NO_FILES_IN_INPUT_PATH = 76
NO_INIT_VALUE = 33
NO_ODE = 32
NO_RETURN = 47
NO_RHS = 28
NO_SEMANTICS = 51
NO_TYPE_ALLOWED = 39
NO_UNIT = 54
NO_VARIABLE_FOUND = 10
NUMERATOR_NOT_ONE = 22
ODE_FUNCTION_NEEDS_CONSISTENT_UNITS = 69
ODE_NEEDS_CONSISTENT_UNITS = 65
ODE_UPDATED = 9
OPERATION_NOT_DEFINED = 57
ORDER_NOT_DECLARED = 23
PARSER_ERROR = 61
PRIORITY_DEFINED_FOR_ONLY_ONE_EVENT_HANDLER = 83
REPEATED_PRIORITY_VALUE = 84
SEVERAL_LHS = 29
SOFT_INCOMPATIBILITY = 45
SPIKE_INPUT_PORT_TYPE_NOT_DEFINED = 11
START_PROCESSING_FILE = 0
START_PROCESSING_MODEL = 13
START_SYMBOL_TABLE_BUILDING = 1
STATE_VARIABLES_NOT_INITIALZED = 77
SYMBOL_NOT_RESOLVED = 49
SYNAPSE_ANALYZED = 530
SYNAPSE_SOLVED_BY_GSL = 520
TARGET_PATH_INFO = 68
TEMPLATED_ARG_TYPES_INCONSISTENT = 66
TEMPLATE_ROOT_PATH_CREATED = 79
TYPE_DIFFERENT_FROM_EXPECTED = 6
TYPE_MISMATCH = 50
TYPE_NOT_DERIVABLE = 3
TYPE_NOT_SPECIFIED = 38
UNKNOWN_TARGET = 62
UNKNOWN_TYPE = 71
VALUE_ASSIGNED_TO_BUFFER = 19
VARIABLE_DEFINED_RECURSIVELY = 18
VARIABLE_NOT_IN_STATE_BLOCK = 26
VARIABLE_REDECLARED = 44
VARIABLE_USED_BEFORE_DECLARATION = 17
VARIABLE_WITH_SAME_NAME_AS_UNIT = 63
VECTOR_IN_NON_VECTOR = 43
VECTOR_PARAMETER_WRONG_BLOCK = 80
VECTOR_PARAMETER_WRONG_SIZE = 82
VECTOR_PARAMETER_WRONG_TYPE = 81
WRONG_NUMBER_OF_ARGS = 27
class pynestml.utils.messages.Messages

Bases: object

This class contains a collection of error messages which enables a centralized maintaining and modifications of those.

classmethod astdatatype_type_symbol_could_not_be_derived()

Unknown type or unit literal. :param provided_type_str: the provided type as a string :type provided_type_str: str

classmethod delta_function_cannot_be_mixed()

Delta function cannot be mixed with expressions.

classmethod delta_function_one_arg(deltafunc)

Delta function takes exactly one argument. :param deltafunc: the delta function node :type name: ASTFunctionCall

classmethod get_analysing_transforming_neuron(name)

Indicates start of code generation :param name: the name of the neuron model :type name: ASTNeuron :return: a nes code,message tuple :rtype: (MessageCode,str)

classmethod get_assignment_not_allowed(name)

Indicates that an assignment to the given element is not allowed. :param name: the name of variable to which an assignment is not allowed. :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_binary_operation_not_defined(lhs, operator, rhs)
classmethod get_binary_operation_type_could_not_be_derived(lhs, operator, rhs, lhs_type, rhs_type)
classmethod get_block_not_defined_correctly(block, missing)

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. :type block: str :param missing: True if missing, False if multiple times. :type missing: bool :return: a message :rtype: (MessageCode,str)

classmethod get_buffer_set_to_conductance_based(buffer)

Returns a message indicating that a buffer has been set to conductance based. :param buffer: the name of the buffer :type buffer: str :return: a message :rtype: (MessageCode,str)

classmethod get_code_generated(model_name, path)

Returns a message indicating that code has been successfully generated for a neuron in a certain path. :param model_name: the name of the neuron. :type model_name: str :param path: the path to the file :type path: str :return: a message :rtype: (MessageCode,str)

classmethod get_compilation_unit_name_collision(name, art1, art2)

Indicates that a name collision with the same neuron inside two artifacts. :param name: the name of the neuron which leads to collision :type name: str :param art1: the first artifact name :type art1: str :param art2: the second artifact name :type art2: str :return: a message :rtype: (MessageCode,str)

classmethod get_continuous_input_port_specified(name, keyword)

Indicates that the continuous time input port has been specified with an inputQualifier keyword. :param name: the name of the buffer :type name: str :param keyword: the keyword :type keyword: list(str) :return: a message :rtype: (MessageCode,str)

classmethod get_convolve_needs_buffer_parameter()
classmethod get_could_not_be_solved()

Indicates that the set of equations could not be solved and will remain unchanged. :return: a message :rtype: (MessageCode,str)

classmethod get_could_not_determine_cond_based(type_str, name)
classmethod get_could_not_resolve(name)

Indicates that the handed over name could not be resolved to a symbol. :param name: the name which could not be resolved :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_data_type_not_specified(name)

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. :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_different_type_rhs_lhs(rhs_expression, lhs_expression, rhs_type, lhs_type)

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 :type rhs_expression: ASTExpression or ASTSimpleExpression :param lhs_expression: the lhs rhs :type lhs_expression: ast_expression or ast_simple_expression :param rhs_type: the type of the rhs :type rhs_type: type_symbol :param lhs_type: the type of the lhs :type lhs_type: TypeSymbol :return: a message :rtype:(MessageCode,str)

classmethod get_emit_spike_function_but_no_output_port()

Indicates that an emit_spike() function was called, but no spiking output port has been defined. :return: a (code, message) tuple :rtype: (MessageCode, str)

classmethod get_equation_var_not_in_state_block(variable_name)

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 :type variable_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_equations_defined_but_integrate_odes_not_called()
classmethod get_equations_solved_by_gls()

Indicates that the set of ODEs as contained in the model will be solved by the gnu scientific library toolchain. :return: a message :rtype: (MessageCode,str)

classmethod get_equations_solved_exactly()

Indicates that all equations of the neuron are solved exactly by the solver script. :return: a message :rtype: (MessageCode,str)

classmethod get_first_arg_not_kernel_or_equation(func_name)

Indicates that the first argument of an rhs is not an equation or kernel. :param func_name: the name of the function :type func_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_function_call_implicit_cast(arg_nr, function_call, expected_type, got_type, castable=False)

Returns a message indicating that an implicit cast has been performed. :param arg_nr: the number of the argument which is cast :type arg_nr: int :param function_call: a single function call :type function_call: ast_function_call :param expected_type: the expected type :type expected_type: type_symbol :param got_type: the got-type :type got_type: TypeSymbol :param castable: is the type castable :type castable: bool :return: a message :rtype: (MessageCode,str)

classmethod get_function_not_declared(name)

Indicates that a function, which is not declared, has been used. :param name: the name of the function. :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_function_redeclared(name, predefined)

Indicates that a function has been redeclared. :param name: the name of the function which has been redeclared. :type name: str :param predefined: True if function is predefined, otherwise False. :type predefined: bool :return: a message :rtype:(MessageCode,str)

classmethod get_implicit_cast_rhs_to_lhs(rhs_type, lhs_type)

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 :type rhs_type: str :param lhs_type: the type of the lhs :type lhs_type: str :return: a message :rtype:(MessageCode,str)

classmethod get_implicit_magnitude_conversion(lhs, rhs, conversion_factor)
classmethod get_input_path_not_found(path)
classmethod get_input_port_type_not_defined(input_port_name: 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 :rtype: (MessageCode,str)

classmethod get_kernel_iv_wrong_type(iv_name: str, actual_type: str, expected_type: str) Tuple[pynestml.utils.messages.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)

Indicates that a kernel variable has been used outside a convolve call. :param name: the name of the kernel :type name: str :return: message :rtype: (MessageCode,str)

classmethod get_kernel_wrong_type(kernel_name: str, differential_order: int, actual_type: str) Tuple[pynestml.utils.messages.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()
classmethod get_model_contains_errors(model_name: str) Tuple[pynestml.utils.messages.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[pynestml.utils.messages.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)

Returns a message indicating that a module has been successfully generated. :param path: the path to the generated file :type path: str :return: a message :rtype: (MessageCode,str)

classmethod get_multiple_keywords(keyword)

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 :type keyword: str :return: a message :rtype: (MessageCode,str)

classmethod get_nest_collision(name)

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 :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_neuron_analyzed(name)

Indicates that the analysis of a neuron will start. :param name: the name of the neuron which will be analyzed. :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_neuron_solved_by_solver(name)

Indicates that a neuron will be solved by the GSL solver inside the model printing process without any modifications to the initial model. :param name: the name of the neuron :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_no_code_generated()

Returns a message indicating that no code will be generated on this run. :return: a message :rtype: (MessageCode,str)

classmethod get_no_files_in_input_path(path: str)
classmethod get_no_init_value(name)

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 :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_no_ode(name)

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 :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_no_return()

Indicates that a given function has no return statement although required. :return: a message :rtype: (MessageCode,str)

classmethod get_no_rhs(name)

Indicates that no right-hand side has been declared for the given variable. :param name: the name of the rhs variable :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_no_variable_found(variable_name)

Returns a message indicating that a variable has not been found. :param variable_name: the name of the variable :type variable_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_not_a_variable(name)

Indicates that a given name does not represent a variable. :param name: the name of the variable :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_not_last_statement(name)

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. :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_not_neuroscience_unit_used(name)

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 :type name: str :return: a nes code,message tuple :rtype: (MessageCode,str)

classmethod get_not_type_allowed(name)

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. :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_ode_function_needs_consistent_units(name, declared_type, expression_type)
classmethod get_ode_needs_consistent_units(name, differential_order, lhs_type, rhs_type)
classmethod get_ode_solution_not_used()

Indicates that an ode has been defined in the model but is not used as part of the neurons solution. :return: a message :rtype: (MessageCode,str)

classmethod get_ode_updated(variable_name)

Returns a message indicating that the ode of a variable has been updated. :param variable_name: the name of the variable :type variable_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_order_not_declared(lhs)

Indicates that the order has not been declared. :param lhs: the name of the variable :type lhs: str :return: a message :rtype: (MessageCode,str)

classmethod get_parser_error()
classmethod get_priority_defined_for_only_one_receive_block(event_handler_port_name: str)
classmethod get_repeated_priorty_value()
classmethod get_second_arg_not_a_spike_port(func_name: str) Tuple[pynestml.utils.messages.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)

Indicates that several left hand sides have been defined. :param names: a list of variables :type names: list(str) :return: a message :rtype: (MessageCode,str)

classmethod get_start_building_symbol_table()

Returns a message that the building for a neuron has been started. :return: a message :rtype: (MessageCode,str)

classmethod get_start_processing_file(file_path)

Returns a message indicating that processing of a file has started :param file_path: the path to the file :type file_path: str :return: message code tuple :rtype: (MessageCode,str)

classmethod get_start_processing_model(model_name: str) Tuple[pynestml.utils.messages.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)
classmethod get_synapse_analyzed(name)

Indicates that the analysis of a synapse will start. :param name: the name of the synapse which will be analyzed. :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_synapse_solved_by_solver(name)

Indicates that a synapse will be solved by the GSL solver inside the model printing process without any modifications to the initial model. :param name: the name of the synapse :type name: str :return: a message :rtype: (MessageCode,str)

classmethod get_template_root_path_created(templates_root_dir: str)
classmethod get_type_could_not_be_derived(rhs)

Returns a message indicating that the type of the rhs rhs could not be derived. :param rhs: an rhs :type rhs: ast_expression or ast_simple_expression :return: a message :rtype: (MessageCode,str)

classmethod get_type_different_from_expected(expected_type, got_type)

Returns a message indicating that the received type is different from the expected one. :param expected_type: the expected type :type expected_type: TypeSymbol :param got_type: the actual type :type got_type: type_symbol :return: a message :rtype: (MessageCode,str)

classmethod get_unary_operation_not_defined(operator, term)
classmethod get_unit_does_not_exist(name)

Indicates that a unit does not exist. :param name: the name of the unit. :type name: str :return: a new code,message tuple :rtype: (MessageCode,str)

classmethod get_unknown_target(target)
classmethod get_value_assigned_to_buffer(buffer_name)

Returns a message indicating that a value has been assigned to a buffer. :param buffer_name: a buffer name :type buffer_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_variable_defined_recursively(variable_name)

Returns a message indicating that a variable is defined recursively. :param variable_name: a variable name :type variable_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_variable_not_defined(variable_name)

Returns a message indicating that a variable is not defined . :param variable_name: a variable name :type variable_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_variable_redeclared(name, predefined)

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 :type name: str :param predefined: True if a pre-defined variable has been redeclared, otherwise False. :type predefined: bool :return: a message :rtype: (MessageCode,str)

classmethod get_variable_used_before_declaration(variable_name)

Returns a message indicating that a variable is used before declaration. :param variable_name: a variable name :type variable_name: str :return: a message :rtype: (MessageCode,str)

classmethod get_variable_with_same_name_as_type(name)

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 :type name: str :return: a tuple containing message code and message text :rtype: (MessageCode,str)

classmethod get_vector_in_non_vector(vector, non_vector)

Indicates that a vector has been used in a non-vector declaration. :param vector: the vector variable :type vector: str :param non_vector: the non-vector lhs :type non_vector: list(str) :return: a message :rtype: (MessageCode,str)

classmethod get_vector_parameter_wrong_block(var, block)
classmethod get_vector_parameter_wrong_size(var, value)
classmethod get_vector_parameter_wrong_type(var)
classmethod get_wrong_number_of_args(function_call, expected, got)

Indicates that a wrong number of arguments has been provided to the function call. :param function_call: a function call name :type function_call: str :param expected: the expected number of arguments :type expected: int :param got: the given number of arguments :type got: int :return: a message :rtype: (MessageCode,str)

classmethod get_wrong_numerator(unit)

Indicates that the numerator of a unit is not 1. :param unit: the name of the unit :type unit: str :return: a message :rtype: (MessageCode,str)

classmethod templated_arg_types_inconsistent(function_name, failing_arg_idx, other_args_idx, failing_arg_type_str, other_type_str)

For templated function arguments, indicates inconsistency between (formal) template argument types and actual derived types. :param name: the name of the neuron model :type name: ASTNeuron :return: a nes code,message tuple :rtype: (MessageCode,str)

classmethod unknown_type(provided_type_str)

Unknown type or unit literal. :param provided_type_str: the provided type as a string :type provided_type_str: str

pynestml.utils.model_installer module

pynestml.utils.model_installer.install_nest(target_path: str, nest_path: str) None

This method can be used to build the generated code and install the resulting extension module into NEST.

Parameters
  • target_path (str) – Path to the target directory, which should contain the generated code artifacts (target platform code and CMake configuration file).

  • nest_path (str) – Path to the NEST installation, which should point to the main directory where NEST is installed. This folder contains the bin, lib(64), include, and share folders of the NEST install. The bin folder should contain the nest-config script, which is accessed by NESTML to perform the installation. This path is the same as that passed through the -Dwith-nest argument of the CMake command before building the generated NEST module. The suffix bin/nest-config will be automatically appended to nest_path.

Raises

pynestml.utils.model_parser module

pynestml.utils.ode_transformer module

pynestml.utils.port_signal_type module

class pynestml.utils.port_signal_type.PortSignalType(value)

Bases: enum.Enum

This enum is used to describe the type of the received or emitted signal.

CONTINUOUS = 2
SPIKE = 1

pynestml.utils.stack module

class pynestml.utils.stack.Stack

Bases: object

This 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.type_caster module

pynestml.utils.type_dictionary module

class pynestml.utils.type_dictionary.TypeDictionary

Bases: dict

pynestml.utils.unit_type module