pynestml.meta_model package
Submodules
pynestml.meta_model.ast_arithmetic_operator module
- class pynestml.meta_model.ast_arithmetic_operator.ASTArithmeticOperator(is_times_op: bool, is_div_op: bool, is_modulo_op: bool, is_plus_op: bool, is_minus_op: bool, is_pow_op: bool, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single arithmetic operator, e.g. +.
No grammar. This part is defined outside the grammar to make processing and storing of models easier and comprehensible.
- is_times_op = False # type
bool
- is_div_op = False # type
bool
- is_modulo_op = False # type
bool
- is_plus_op = False # type
bool
- is_minus_op = False # type
bool
- is_pow_op = False # type
bool
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
pynestml.meta_model.ast_assignment module
- class pynestml.meta_model.ast_assignment.ASTAssignment(lhs: ASTVariable | None = None, is_direct_assignment: bool = False, is_compound_sum: bool = False, is_compound_minus: bool = False, is_compound_product: bool = False, is_compound_quotient: bool = False, rhs: ASTExpression | None = None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store assignments. Grammar:
- assignmentlhs_variable=variable
(directAssignment=”=” | compoundSum=”+=” | compoundMinus=”-=” | compoundProduct=”*=” | compoundQuotient=”/=”) rhs;
- lhs = None
- is_direct_assignment = False
- is_compound_sum = False
- is_compound_minus = False
- is_compound_product = False
- is_compound_quotient = False
- rhs = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- construct_equivalent_direct_assignment_rhs(operator, lhs_variable, rhs_in_brackets)
- extract_operator_from_compound_assignment()
- get_bracketed_rhs_expression()
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_expression()
Returns the right-hand side rhs. :return: rhs object. :rtype: ast_expression
- get_lhs_variable_as_expression()
- get_variable()
Returns the left-hand side variable. :return: left-hand side variable object. :rtype: ASTVariable
pynestml.meta_model.ast_bit_operator module
- class pynestml.meta_model.ast_bit_operator.ASTBitOperator(is_bit_and=False, is_bit_xor=False, is_bit_or=False, is_bit_shift_left=False, is_bit_shift_right=False, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single bit operator. Grammar:
bitOperator : (bitAnd=”&”| bitXor=”^” | bitOr=”|” | bitShiftLeft=”<<” | bitShiftRight=”>>”);
- is_bit_and = False
- is_bit_xor = False
- is_bit_or = False
- is_bit_shift_left = False
- is_bit_shift_right = False
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
pynestml.meta_model.ast_block_with_variables module
- class pynestml.meta_model.ast_block_with_variables.ASTBlockWithVariables(is_state=False, is_parameters=False, is_internals=False, declarations=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a block of variable declarations. ast_block_with_variables.py represent a block with variables, e.g.:
- state:
y0, y1, y2, y3 mV [y1 > 0; y2 > 0]
attribute state: true if the varblock is a state. attribute parameter: true if the varblock is a parameter. attribute internal: true if the varblock is a state internal. Grammar:
- blockWithVariables:
blockType=(“state”|”parameters”|”internals”) BLOCK_OPEN
(declaration | NEWLINE)*
BLOCK_CLOSE;
- is_state = False
- is_parameters = False
- is_internals = False
- declarations = None
- clear()
Clears the list of declarations in this block.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_declarations()
Returns the set of stored declarations. :return: set of declarations :rtype: set(ASTDeclaration)
pynestml.meta_model.ast_comparison_operator module
- class pynestml.meta_model.ast_comparison_operator.ASTComparisonOperator(is_lt=False, is_le=False, is_eq=False, is_ne=False, is_ne2=False, is_ge=False, is_gt=False, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single comparison operator. Grammar:
comparisonOperator : (lt=”<” | le=”<=” | eq=”==” | ne=”!=” | ne2=”<>” | ge=”>=” | gt=”>”);
- is_lt = False
- is_le = False
- is_eq = False
- is_ne = False
- is_ne2 = False
- is_ge = False
- is_gt = False
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
pynestml.meta_model.ast_compound_stmt module
- class pynestml.meta_model.ast_compound_stmt.ASTCompoundStmt(if_stmt=None, while_stmt=None, for_stmt=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store compound statements. Grammar:
- compoundStmtifStmt
- forStmtwhileStmt;
- if_stmt = None
- while_stmt = None
- for_stmt = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_for_stmt()
Returns the for statement. :return: the for statement. :rtype: ASTForStmt
- get_if_stmt()
Returns the “if” statement. :return: the “if” statement. :rtype: ASTIfStmt
- get_while_stmt()
Returns the while statement. :return: the while statement. :rtype: ASTWhileStmt
- is_for_stmt()
Returns whether it is an “for” statement or not. :return: True if “for” stmt, False else. :rtype: bool
- is_if_stmt()
Returns whether it is an “if” statement or not. :return: True if if stmt, False else. :rtype: bool
- is_while_stmt()
Returns whether it is an “while” statement or not. :return: True if “while” stmt, False else. :rtype: bool
pynestml.meta_model.ast_data_type module
- class pynestml.meta_model.ast_data_type.ASTDataType(is_integer=False, is_real=False, is_string=False, is_boolean=False, is_void=False, unit_type: ASTUnitType | None = None, type_symbol=None, *args, **kwargs)
Bases:
ASTNodeA datatype class as used to store a datatype of an element. ASTDataType. Represents predefined datatypes and gives a possibility to use an unit datatype. @attribute boolean getters for integer, real, … @attribute unitType a SI datatype datatype : “integer”
“real”“string”“boolean”“void”unitType;- is_integer = False
- is_real = False
- is_string = False
- is_boolean = False
- is_void = False
- unit_type = None # a unit type is not a boolean, but a concrete object
- type_symbol = None # the corresponding type symbol
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_type_symbol()
Returns the corresponding type symbol. :return: a single type symbol element. :rtype: type_symbol
- get_unit_type()
Returns the unit type. :return: the unit type object. :rtype: ASTUnitType
- is_unit_type()
Returns whether this is a unit type or not. :return: True if unit type typed, otherwise False. :rtype: bool
- set_type_symbol(type_symbol)
Updates the current type symbol to the handed over one. :param type_symbol: a new type symbol element. :type type_symbol: TypeSymbol.
pynestml.meta_model.ast_declaration module
- class pynestml.meta_model.ast_declaration.ASTDeclaration(is_recordable: bool = False, is_inline_expression: bool = False, _variables: List[ASTVariable] | None = None, data_type: ASTDataType | None = None, size_parameter: ASTSimpleExpression | ASTExpression | None = None, expression: ASTExpression | None = None, invariant: ASTExpression | None = None, decorators=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store declarations. ASTDeclaration A variable declaration. It can be a simple declaration defining one or multiple variables: “a,b,c real = 0”. @attribute hide is true iff. declaration is not traceable. @attribute function is true iff. declaration is an function. @attribute vars List with variables @attribute Datatype Obligatory data type, e.g. “real” or “mV/s” @attribute sizeParameter An optional array parameter. E.g. “tau_syn ms[n_receptors]” @attribute expr An optional initial rhs, e.g. “a real = 10+10” @attribute invariants List with optional invariants. Grammar:
- declaration :
(“recordable”)? (“function”)? variable (“,” variable)* datatype (“[” sizeParameter=NAME “]”)? ( “=” rhs)? (“[[” invariant=rhs “]]”)?;
- is_recordable = False
- is_inline_expression = False
- variables = None
- data_type = None
- size_parameter = None
- expression = None
- invariant = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_data_type()
Returns the data type. :return: a data type object. :rtype: ASTDataType
- get_decorators()
- get_expression()
Returns the right-hand side rhs. :return: the right-hand side rhs. :rtype: ASTExpression
- get_invariant()
Returns the invariant. :return: the invariant :rtype: ASTExpression
- get_size_parameter() ASTSimpleExpression | ASTExpression | None
Returns the size parameter. :return: the size parameter.
- get_variables()
Returns the set of left-hand side variables. :return: a list of variables. :rtype: list(ASTVariables)
- has_expression() bool
Returns whether the declaration has a right-hand side rhs or not. :return: True if right-hand side rhs declared, else False.
- has_invariant()
Returns whether the declaration has a invariant or not. :return: True if has invariant, otherwise False. :rtype: bool
- has_size_parameter() bool
Returns whether the declaration has a size parameter or not. :return: True if has size parameter, else False.
- set_expression(expr: ASTExpression) None
- set_size_parameter(_parameter: ASTSimpleExpression | ASTExpression | None)
Updates the current size parameter to a new value. :param _parameter: the size parameter
pynestml.meta_model.ast_elif_clause module
- class pynestml.meta_model.ast_elif_clause.ASTElifClause(condition, stmts_body: ASTStmtsBody, *args, **kwargs)
Bases:
ASTNodeThis class is used to store elif-clauses.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_condition() ASTExpression
Returns the condition of the elif. :return: the condition.
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the body of statements.
pynestml.meta_model.ast_else_clause module
- class pynestml.meta_model.ast_else_clause.ASTElseClause(stmts_body: ASTStmtsBody, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single else-clause.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the body of statements.
pynestml.meta_model.ast_equations_block module
- class pynestml.meta_model.ast_equations_block.ASTEquationsBlock(declarations, *args, **kwargs)
Bases:
ASTNodeThis class is used to store an equations block.
- clear()
Deletes all declarations as stored in this block.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_declarations()
Returns the block of definitions. :return: the block :rtype: list(ASTInlineExpression|ASTOdeEquation)
- get_inline_expressions() Sequence[ASTInlineExpression]
Returns a list of all inline expressions in this block. :return: a list of all inline expressions.
- get_kernels() Sequence[ASTKernel]
Returns a list of all kernels in this block. :return: a list of all kernels.
- get_ode_equations() Sequence[ASTOdeEquation]
Returns a list of all ode equations in this block. :return: a list of all ode equations.
pynestml.meta_model.ast_expression module
- class pynestml.meta_model.ast_expression.ASTExpression(is_encapsulated: bool = False, unary_operator: ASTUnaryOperator | None = None, is_logical_not: bool = False, expression: ASTExpression | None = None, lhs: ASTExpression | None = None, binary_operator: ASTLogicalOperator | ASTComparisonOperator | ASTBitOperator | ASTArithmeticOperator | None = None, rhs: ASTExpression | None = None, condition: ASTExpression | None = None, if_true: ASTExpression | None = None, if_not: ASTExpression | None = None, has_delay: bool = False, *args, **kwargs)
Bases:
ASTExpressionNodeASTExpr, i.e., several subexpressions combined by one or more operators, e.g., 10mV + V_m - (V_reset * 2)/ms …. or a simple rhs, e.g. 10mV. Grammar:
- rhsleftParentheses=”(” rhs rightParentheses=”)”
- <assoc=right> base=rhs powOp=”**” exponent=rhsunaryOperator term=rhsleft=rhs (timesOp=”*” | divOp=”/” | moduloOp=”%”) right=rhsleft=rhs (plusOp=”+” | minusOp=”-”) right=rhsleft=rhs bitOperator right=rhsleft=rhs comparisonOperator right=rhslogicalNot=”not” rhsleft=rhs logicalOperator right=rhscondition=rhs “?” ifTrue=rhs “:” ifNot=rhssimpleExpression
;
- # encapsulated or with unary operator or with a logical not or just a simple rhs.
- is_encapsulated = False
- is_logical_not = False
- unary_operator = None
- expression = None
- # lhs and rhs combined by an operator
- lhs = None
- binary_operator = None
- rhs = None
- # ternary operator
- condition = None
- if_true = None
- if_not = None
- # simple rhs
- simple_expression = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_binary_operator()
Returns the binary operator. :return: the binary operator. :rtype: one of ASTLogicalOperator,ASTComparisonOperator,ASTBitOperator,ASTArithmeticOperator
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_condition()
Returns the condition rhs. :return: the condition rhs. :rtype: ASTExpression
- get_expression()
Returns the rhs. :return: the rhs. :rtype: ASTExpression
- get_function_calls()
Returns a list of all function calls as used in this rhs :return: a list of all function calls in this rhs. :rtype: list(ASTFunctionCall)
- get_has_delay()
Returns the has_delay parameter :return:
- get_if_not()
Returns the rhs used in the case that the condition does not hold. :return: the if-not condition. :rtype: ASTExpression
- get_if_true()
Returns the rhs used in the case that the condition holds. :return: the if-true condition. :rtype: ASTExpression
- get_lhs()
Returns the left-hand side rhs. :return: the left-hand side rhs. :rtype: ASTExpression
- get_rhs()
Returns the right-hand side rhs. :return: the right-hand side rhs. :rtype: ASTExpression
- get_unary_operator()
Returns the unary operator. :return: the unary operator. :rtype: ASTUnaryOperator.
- get_units()
Returns a list of all units as use in this rhs. :return: a list of all used units. :rtype: list(ASTVariable)
- get_variables()
Returns a list of all variables as used in this rhs. :return: a list of variables. :rtype: list(ASTVariable)
- is_compound_expression()
Returns whether it is a compound rhs, e.g., 10+10 :return: True if compound rhs, otherwise False. :rtype: bool
- is_ternary_operator()
Returns whether it is a ternary operator. :return: True if ternary operator, otherwise False. :rtype: bool
- is_unary_operator()
Returns whether the rhs uses an unary operator. :return: True if unary operator, otherwise False. :rtype: bool
pynestml.meta_model.ast_expression_node module
- class pynestml.meta_model.ast_expression_node.ASTExpressionNode(*args, **kwargs)
Bases:
ASTNodeThis class is not a part of the grammar but is used to store commonalities of expression-type nodes.
This class is abstract, thus no instances can be created.
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- property type
pynestml.meta_model.ast_external_variable module
- class pynestml.meta_model.ast_external_variable.ASTExternalVariable(name, altname=None, altscope=None, *args, **kwargs)
Bases:
ASTVariableThis class is used to store a single “external” variable: a variable the value of which is obtained during runtime from a neuron’s postsynaptic partner.
- clone()
Return a clone (“deep copy”) of this node.
- get_alternate_name()
- get_scope()
Returns the scope of this element. :return: a scope object. :rtype: Scope
- update_alt_scope(scope)
pynestml.meta_model.ast_for_stmt module
- class pynestml.meta_model.ast_for_stmt.ASTForStmt(variable, start_from, end_at, step, stmts_body: ASTStmtsBody, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a “for” statement.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_end_at()
Returns the to-statement. :return: the rhs indicating the finish value. :rtype: ast_expression
- get_start_from()
Returns the from-statement. :return: the rhs indicating the start value. :rtype: ast_expression
- get_step()
Returns the length of a single step. :return: the length as a float. :rtype: float
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the body of statements.
- get_variable()
Returns the name of the step variable. :return: the name of the step variable. :rtype: str
pynestml.meta_model.ast_function module
- class pynestml.meta_model.ast_function.ASTFunction(name: str, parameters: List[ASTParameter], return_type: ASTDataType | None, stmts_body: ASTStmtsBody, type_symbol=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a user-defined function. ASTFunction a function definition:
- function set_V_m(v mV):
y3 = v - E_L
@attribute name Functionname. @attribute parameter A single parameter. @attribute returnType Complex return type, e.g. String @attribute primitiveType Primitive return type, e.g. int @attribute block Implementation of the function. Grammar: function: “function” NAME “(” (parameter (“,” parameter)*)? “)” (returnType=datatype)?
- BLOCK_OPEN
block
BLOCK_CLOSE;
- name = None
- parameters = None
- return_type = None
- block = None
- # the corresponding type symbol
- type_symbol = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_name()
Returns the name of the function. :return: the name of the function. :rtype: str
- get_parameters() List[ASTParameter]
Returns the list of parameters. :return: a parameters object containing the list.
- get_return_type()
Returns the return type of function. :return: the return type :rtype: ast_data_type
- get_stmts_body() ASTStmtsBody
Returns the body containing the statements. :return: the body
- get_type_symbol()
Returns the type symbol of this rhs. :return: a single type symbol. :rtype: type_symbol
- has_parameters() bool
Returns whether parameters have been defined. :return: True if parameters defined, otherwise False.
- has_return_type()
Returns whether return a type has been defined. :return: True if return type defined, otherwise False. :rtype: bool
- set_type_symbol(type_symbol)
Updates the current type symbol to the handed over one. :param type_symbol: a single type symbol object. :type type_symbol: type_symbol
pynestml.meta_model.ast_function_call module
- class pynestml.meta_model.ast_function_call.ASTFunctionCall(callee_name, function_call_args, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single function call. ASTFunctionCall Represents a function call, e.g. myFun(“a”, “b”). @attribute name The (qualified) name of the function @attribute args Comma separated list of expressions representing parameters. Grammar:
functionCall : calleeName=NAME “(” (rhs (“,” rhs)*)? “)”;
- callee_name = None
- args = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_args() List[ASTParameter]
Returns the list of arguments. :return: the list of arguments.
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_name()
Returns the name of the called function. :return: the name of the function. :rtype: str.
- has_args()
Returns whether function call has arguments or not. :return: True if has arguments, otherwise False. :rtype: bool
pynestml.meta_model.ast_if_clause module
- class pynestml.meta_model.ast_if_clause.ASTIfClause(condition, stmts_body: ASTStmtsBody, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single
if-clause.- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_condition()
Returns the condition of the if statement. :return: the condition. :rtype: ASTExpression
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the body of statements.
pynestml.meta_model.ast_if_stmt module
- class pynestml.meta_model.ast_if_stmt.ASTIfStmt(if_clause, elif_clauses=None, else_clause=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single if block. Grammar:
- ifStmtifClause
elifClause* (elseClause)? BLOCK_CLOSE;
- if_clause = None
- elif_clauses = None
- else_clause = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_elif_clauses()
Returns a list of elif-clauses. :return: a list of elif-clauses. :rtype: List[ASTElifClause]
- get_else_clause()
Returns the else-clause. :return: the else-clause. :rtype: ASTElseClause
- get_if_clause()
Returns the if-clause. :return: the if clause :rtype: ASTfClause
- has_elif_clauses()
Returns whether object contains elif clauses. :return: True if at leas one elif clause, False else. :rtype: bool
- has_else_clause()
Returns whether object contains elif clauses. :return: True if object contains an else-clause, False else. :rtype: bool
pynestml.meta_model.ast_inline_expression module
- class pynestml.meta_model.ast_inline_expression.ASTInlineExpression(is_recordable=False, variable_name=None, data_type=None, expression=None, decorators=None, *args, **kwargs)
Bases:
ASTNode- Stores a single declaration of an inline expression, e.g.,
inline v_init mV = V_m - 50mV.
- Grammar:
inline : (recordable=”recordable”)? INLINE_KEYWORD variableName=NAME datatype “=” rhs;
- is_recordable = False
- variable_name = None
- data_type = None
- expression = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_data_type()
Returns the data type as an object of ASTDatatype. :return: the type as an object of ASTDatatype. :rtype: ast_data_type
- get_decorators()
- get_expression()
Returns the rhs as an object of ASTExpression. :return: the rhs as an object of ASTExpression. :rtype: ast_expression
- get_variable_name()
Returns the variable name. :return: the name of the variable. :rtype: str
pynestml.meta_model.ast_input_block module
- class pynestml.meta_model.ast_input_block.ASTInputBlock(input_definitions=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store the input block of a model, e.g.:
input: spike_in <- spike current_in pA <- continuous
- input_definitions = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_input_ports() List[ASTInputPort]
Returns the list of input ports. :return: a list of input ports
pynestml.meta_model.ast_input_port module
- class pynestml.meta_model.ast_input_port.ASTInputPort(name: str, signal_type: PortSignalType, size_parameter: ASTSimpleExpression | ASTExpression | None = None, data_type: ASTDataType | None = None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a declaration of an input port. ASTInputPort represents a single input port, e.g.:
spike_in <- spike
@attribute name: The name of the input port. @attribute sizeParameter: Optional size parameter for multisynapse neuron. @attribute datatype: Optional data type of the port. @attribute isSpike: Indicates that this input port accepts spikes. @attribute isContinuous: Indicates that this input port accepts continuous time input.
- clone() ASTInputPort
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_datatype() ASTDataType
Returns the currently used data type of this port. :return: a single data type object.
- get_size_parameter() ASTSimpleExpression | ASTExpression | None
Returns the size parameter. :return: the size parameter.
- has_datatype()
Returns whether this port has a defined data type or not. :return: True if it has a datatype, otherwise False.
- has_size_parameter() bool
Returns whether a size parameter has been defined. :return: True if size has been used, otherwise False.
pynestml.meta_model.ast_kernel module
- class pynestml.meta_model.ast_kernel.ASTKernel(variables, expressions, *args, **kwargs)
Bases:
ASTNodeThis class is used to store kernels. Grammar:
kernel : KERNEL_KEYWORD variable EQUALS expression (COMMA variable EQUALS expression)* (SEMICOLON)?;
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_expressions()
Returns the right-hand side rhs. :return: the rhs :rtype: ast_expression
- get_variable_names()
Returns the variable of the left-hand side. :return: the variable :rtype: ast_variable
- get_variables()
Returns the variable of the left-hand side. :return: the variable :rtype: ast_variable
pynestml.meta_model.ast_logical_operator module
- class pynestml.meta_model.ast_logical_operator.ASTLogicalOperator(is_logical_and=False, is_logical_or=False, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single logical operator. Grammar:
logicalOperator : (logicalAnd=”and” | logicalOr=”or”);
- is_logical_and = False
- is_logical_or = False
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
pynestml.meta_model.ast_model module
- class pynestml.meta_model.ast_model.ASTModel(name: str, body: ASTModelBody, artifact_name=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to stuff common to neurons and synapses
- add_to_internals_block(declaration: ASTDeclaration, index: int = -1, run_symboltable_visitor: bool = True) None
Adds the handed over declaration the internals block :param declaration: a single declaration
- add_to_state_block(declaration: ASTDeclaration) None
Adds the handed over declaration to an arbitrary state block. A state block will be created if none exists. :param declaration: a single declaration.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- create_empty_update_block()
Create an empty update block. Only makes sense if one does not already exist.
- get_all_kernels()
- get_artifact_name() str
Returns the name of the artifact this model has been stored in. :return: the name of the file
- get_body() ASTModelBody
Return the body of the model. :return: the model body
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_continuous_input_port_names() List[str]
Returns a list of all continuous time input ports defined in the model.
- get_continuous_input_ports() List[VariableSymbol]
Returns a list of all continuous time input ports defined in the model.
- get_current_buffers()
Returns a list of all current buffers defined in the model. :return: a list of all current input buffers. :rtype: list(VariableSymbol)
- get_default_delay_dtype()
- get_default_delay_expression()
- get_default_delay_variable()
- get_equations() List[ASTOdeEquation]
Returns all ode equations as defined in this neuron. :return list of ode-equations
- get_equations_blocks() List[ASTEquationsBlock]
Returns a list of all
equationsblocks defined in this body. :return: a list of equations-blocks.
- get_functions() List[ASTFunction]
Returns a list of all function block declarations in this body. :return: a list of function declarations.
- get_inline_expression_symbols() List[VariableSymbol]
Returns a list of all inline expression symbols defined in the model. :return: a list of symbols
- get_input_blocks() List[ASTInputBlock]
Returns a list of all input-blocks defined. :return: a list of defined input-blocks.
- get_input_buffers()
Returns a list of all defined input buffers. :return: a list of all input buffers. :rtype: list(VariableSymbol)
- get_input_ports() List[VariableSymbol]
Returns a list of all defined input ports. :return: a list of all input ports.
- get_internal_symbols() List[VariableSymbol]
Returns a list of all internals symbol defined in the model. :return: a list of internals symbols.
- get_internals_blocks() List[ASTBlockWithVariables]
Returns a list of all internals blocks defined in this body. :return: a list of internals-blocks.
- get_non_inline_state_symbols() List[VariableSymbol]
Returns a list of all state symbols as defined in the model which are not marked as inline expressions. :return: a list of symbols
- get_ode_defined_symbols()
Returns a list of all variable symbols which have been defined in th state blocks and are provided with an ode. :return: a list of state variables with odes :rtype: list(VariableSymbol)
- get_on_condition_blocks() List[ASTOnConditionBlock]
- get_on_receive_block(port_name: str) ASTOnReceiveBlock | None
- get_on_receive_blocks() List[ASTOnReceiveBlock]
- get_output_blocks() List[ASTOutputBlock]
Returns a list of all output-blocks defined. :return: a list of defined output-blocks.
- get_parameter_invariants()
Returns a list of all invariants of all parameters. :return: a list of rhs representing invariants :rtype: list(ASTExpression)
- get_parameter_symbols()
Returns a list of all parameter symbol defined in the model. :return: a list of parameter symbols. :rtype: list(VariableSymbol)
- get_parameter_variables() List[ASTVariable]
Returns a list of all parameters. :return:
- get_parameters_blocks() List[ASTBlockWithVariables]
Returns a list of all parameter blocks defined in this body. :return: a list of parameters-blocks.
- get_spike_buffers()
Returns a list of all spike input buffers defined in the model. :return: a list of all spike input buffers. :rtype: list(VariableSymbol)
- get_spike_input_port_names() List[str]
Returns a list of all spike input ports defined in the model.
- get_spike_input_ports() List[VariableSymbol]
Returns a list of all spike input ports defined in the model.
- get_state_blocks() List[ASTBlockWithVariables]
Returns a list of all state blocks defined in this body. :return: a list of state-blocks.
- get_state_declarations()
Returns a list of initial values declarations made in this neuron. :return: a list of initial values declarations :rtype: list(ASTDeclaration)
- get_state_symbols() List[VariableSymbol]
Returns a list of all state symbol defined in the model. :return: a list of state symbols.
- get_state_symbols_without_ode()
Returns a list of all elements which have been defined in the state block. :return: a list of of state variable symbols. :rtype: list(VariableSymbol)
- get_state_variables() List[ASTVariable]
Returns a list of all state variables. :return:
- get_update_blocks() List[ASTUpdateBlock]
Returns a list of all update blocks defined in this body. :return: a list of update-block elements.
- get_vector_state_symbols() List[VariableSymbol]
Returns a list of all state symbols that are vectors :return: a list of vector state symbols
- get_vector_symbols() List[VariableSymbol]
Returns a list of all the vector variables declared in State, Parameters, and Internals block :return: a list of vector symbols
- has_delay_variables() bool
This method indicates if the neuron has variables with a delay parameter. :return: True if variables with delay parameter exist, False otherwise.
- has_state_vectors() bool
This method indicates if the neuron has variables defined as vectors. :return: True if vectors are defined, false otherwise.
- has_vector_port() bool
This method indicates whether this neuron contains input ports defined vector-wise. :return: True if vector ports defined, otherwise False.
- is_array_buffer()
This method indicates whether this neuron uses buffers defined vector-wise. :return: True if vector buffers defined, otherwise False. :rtype: bool
- is_multisynapse_spikes() bool
Returns whether this neuron uses multi-synapse inputs. :return: True if multi-synaptic, otherwise False.
- print_comment(prefix: str = '') str
Prints the header comment of this neuron. :param prefix: a prefix string :return: the comment.
- remove_equations_block() None
Deletes all equations blocks. By construction as checked through cocos there is only one there.
- set_default_delay(var, expr, dtype)
- set_name(name)
Set the name of the model.
pynestml.meta_model.ast_model_body module
- class pynestml.meta_model.ast_model_body.ASTModelBody(body_elements, *args, **kwargs)
Bases:
ASTNodeThis class is used to store the body of a neuron or synapse, an object containing all the definitions. ASTModelBody The body of the neuron, e.g. internal, state, parameter… Grammar:
- bodyBLOCK_OPEN
(NEWLINE | blockWithVariables | updateBlock | equationsBlock | inputBlock | outputBlock | function)* BLOCK_CLOSE;
- body_elements = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_body_elements()
Returns the list of body elements. :return: a list of body elements. :rtype: list()
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_equations_blocks() List[ASTEquationsBlock]
Returns a list of all equations blocks defined in this body. :return: a list of equations-blocks.
- get_functions()
Returns a list of all function block declarations in this body. :return: a list of function declarations. :rtype: list(ASTFunction)
- get_input_blocks() List[ASTInputBlock]
Returns a list of all input-blocks defined. :return: a list of defined input-blocks.
- get_internals_blocks() List[ASTBlockWithVariables]
Returns a list of all internals blocks defined in this body. :return: a list of internals-blocks. :rtype: list(ASTBlockWithVariables)
- get_on_condition_blocks() List[ASTOnConditionBlock]
- get_on_receive_block(port_name) ASTOnReceiveBlock | None
- get_on_receive_blocks() List[ASTOnReceiveBlock]
Returned blocks are sorted descending, from high priority to low priority, if priority options were specified.
- get_output_blocks() List[ASTOutputBlock]
Returns a list of all output-blocks defined. :return: a list of defined output-blocks. :rtype: list(ASTOutputBlock)
- get_parameters_blocks() List[ASTBlockWithVariables]
Returns a list of all parameter blocks defined in this body. :return: a list of parameters-blocks.
- get_spike_input_ports() List[ASTInputPort]
Returns a list of all spike input ports defined in the model. :return: a list of all spike input ports
- get_state_blocks() List[ASTBlockWithVariables]
Returns a list of all state blocks defined in this body. :return: a list of state-blocks.
- get_update_blocks() List[ASTUpdateBlock]
Returns a list of all update blocks defined in this body. :return: a list of update-block elements.
pynestml.meta_model.ast_namespace_decorator module
- class pynestml.meta_model.ast_namespace_decorator.ASTNamespaceDecorator(namespace: str = '', name: str = '', *args, **kwargs)
Bases:
ASTNodeNamespace decorator, for example “@nest::delay”.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
pynestml.meta_model.ast_nestml_compilation_unit module
- class pynestml.meta_model.ast_nestml_compilation_unit.ASTNestMLCompilationUnit(model_list: List[ASTModel] | None = None, artifact_name=None, *args, **kwargs)
Bases:
ASTNodeStore a collection of processed ASTModels.
- add_model(model: ASTModel)
Expects an instance of a model which is added to the collection. :param neuron: an instance of a model
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- delete_model(model: ASTModel) bool
Expects an instance of a model which is deleted from the collection. :param model: an instance :return: True if element deleted from list, False else.
pynestml.meta_model.ast_node module
- class pynestml.meta_model.ast_node.ASTNode(source_position: ASTSourceLocation | None = None, scope: Scope | None = None, comment: str | None = None, pre_comments: List[str] | None = None, in_comment: str | None = None, implicit_conversion_factor: float | None = None)
Bases:
objectThis class is not a part of the grammar but is used to store commonalities of all possible meta_model classes, e.g., the source position.
This class is abstract, thus no instances can be created.
- source_position = None
- scope = None
- comment = None
- #
- pre_comments = list()
- in_comment = None
- #
- implicit_conversion_factor = None
- accept(visitor)
Double dispatch for visitor pattern. :param visitor: A visitor. :type visitor: Inherited from ASTVisitor.
- abstract clone()
Return a deep copy of this node.
- abstract equals(other: ASTNode) bool
The equals operation. :param other: a different AST node. :return: True if equal, otherwise False.
- abstract get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_comment()
Returns the comment of this element. :return: a comment. :rtype: str
- get_comments()
- get_implicit_conversion_factor() float | None
Returns the factor installed as implicitConversionFactor for this expression :return: the conversion factor, if present, or None
- get_scope()
Returns the scope of this element. :return: a scope object. :rtype: Scope
- get_source_position()
Returns the source position of the element. :return: a source position object. :rtype: ASTSourceLocation
- has_comment()
Indicates whether this element stores a comment. :return: True if has comment, otherwise False. :rtype: bool
- print_comment(prefix: str = '') str
Prints the comment of this meta_model element. :param prefix: a prefix string :return: a comment
- set_comment(comment)
Updates the comment of this element. :param comment: a comment :type comment: str
- set_implicit_conversion_factor(implicit_factor: float | None) None
Sets a factor that, when applied to the (unit-typed) expression, converts it to the magnitude of the context where it is used. eg. Volt + milliVolt needs to either be 1000*Volt + milliVolt or Volt + 0.001 * milliVolt :param implicit_factor: the factor to be installed
- set_source_position(new_position)
Updates the source position of the element. :param new_position: a new source position :type new_position: ASTSourceLocation :return: a source position object. :rtype: ASTSourceLocation
- update_scope(_scope)
Updates the scope of this element. :param _scope: a scope object. :type _scope: Scope
pynestml.meta_model.ast_node_factory module
- class pynestml.meta_model.ast_node_factory.ASTNodeFactory
Bases:
objectAn implementation of the factory pattern for an easier initialization of new AST nodes.
- classmethod create_ast_arithmetic_operator(is_times_op: bool = False, is_div_op: bool = False, is_modulo_op: bool = False, is_plus_op: bool = False, is_minus_op: bool = False, is_pow_op: bool = False, source_position: ASTSourceLocation | None = None) ASTArithmeticOperator
- classmethod create_ast_assignment(lhs: ASTVariable = None, is_direct_assignment: bool = False, is_compound_sum: bool = False, is_compound_minus: bool = False, is_compound_product: bool = False, is_compound_quotient: bool = False, expression: Union(ASTSimpleExpression, ASTExpression) = None, source_position: ASTSourceLocation = None) ASTAssignment
- classmethod create_ast_bit_operator(is_bit_and: bool = False, is_bit_xor: bool = False, is_bit_or: bool = False, is_bit_shift_left: bool = False, is_bit_shift_right: bool = False, source_position: ASTSourceLocation | None = None) ASTBitOperator
- classmethod create_ast_block_with_variables(is_state: bool = False, is_parameters: bool = False, is_internals: bool = False, declarations: bool = None, source_position: list(ASTDeclaration) = None) ASTBlockWithVariables
- classmethod create_ast_comparison_operator(is_lt: bool = False, is_le: bool = False, is_eq: bool = False, is_ne: bool = False, is_ne2: bool = False, is_ge: bool = False, is_gt: bool = False, source_position: ASTSourceLocation | None = None) ASTComparisonOperator
- classmethod create_ast_compound_expression(lhs: Union(ASTExpression, ASTSimpleExpression), binary_operator: Union(ASTLogicalOperator, ASTBitOperator, ASTComparisonOperator, ASTArithmeticOperator), rhs: Union(ASTExpression, ASTSimpleExpression), source_position: ASTSourceLocation) ASTExpression
The factory method used to create compound expressions, e.g. 10mV + V_m.
- classmethod create_ast_compound_stmt(if_stmt: ASTIfStmt, while_stmt: ASTWhileStmt, for_stmt: ASTForStmt, source_position: ASTSourceLocation) ASTCompoundStmt
- classmethod create_ast_data_type(is_integer: bool = False, is_real: bool = False, is_string: bool = False, is_boolean: bool = False, is_void: bool = False, is_unit_type: ASTUnitType | None = None, source_position: ASTSourceLocation | None = None) ASTDataType
- classmethod create_ast_declaration(is_recordable: bool = False, is_inline_expression: bool = False, variables=None, data_type=None, size_parameter=None, expression=None, invariant=None, source_position=None, decorators=None) ASTDeclaration
- classmethod create_ast_elif_clause(condition: ASTExpression | ASTSimpleExpression, block: ASTStmtsBody, source_position: ASTSourceLocation = None) ASTElifClause
- classmethod create_ast_else_clause(block: ASTStmtsBody, source_position: ASTSourceLocation) ASTElseClause
- classmethod create_ast_equations_block(declarations: list | None = None, source_position: ASTSourceLocation | None = None) ASTEquationsBlock
- classmethod create_ast_expression(is_encapsulated: bool = False, unary_operator: ASTUnaryOperator = None, is_logical_not: bool = False, expression: ASTExpression | ASTSimpleExpression = None, source_position: ASTSourceLocation = None) ASTExpression
The factory method used to create rhs which are either encapsulated in parentheses (e.g., (10mV)) OR have a unary (e.g., ~bitVar), OR are negated (e.g., not logVar), or are simple rhs (e.g., 10mV).
- classmethod create_ast_for_stmt(variable: str, start_from: Union(ASTSimpleExpression, ASTExpression), end_at: Union(ASTSimpleExpression, ASTExpression), step: float = 0, block: ASTStmtsBody = None, source_position: ASTSourceLocation = None) ASTForStmt
- classmethod create_ast_function(name: str, parameters: None | list(ASTParameter), return_type: ASTDataType | None, block: ASTStmtsBody, source_position: ASTSourceLocation) ASTFunction
- classmethod create_ast_function_call(callee_name: str, args: None | list(ASTExpression | ASTSimpleExpression), source_position: ASTSourceLocation = None) ASTFunctionCall
- classmethod create_ast_if_clause(condition: ASTSimpleExpression | ASTExpression, block: ASTStmtsBody, source_position: ASTSourceLocation) ASTIfClause
- classmethod create_ast_if_stmt(if_clause: ASTIfClause, elif_clauses: None | list(ASTElifClause), else_clause: None | ASTElseClause, source_position: ASTSourceLocation) ASTIfStmt
- classmethod create_ast_inline_expression(variable_name: str, data_type: ASTDataType, expression: ASTExpression | ASTSimpleExpression, source_position: ASTSourceLocation, is_recordable: bool = False, decorators: list | None = None) ASTInlineExpression
- classmethod create_ast_input_block(input_definitions: list(ASTInputPort), source_position: ASTSourceLocation) ASTInputBlock
- classmethod create_ast_input_port(name: str, size_parameter: str, data_type: ASTDataType | None, signal_type: PortSignalType | None, source_position: ASTSourceLocation) ASTInputPort
- classmethod create_ast_logical_operator(is_logical_and: bool = False, is_logical_or: bool = False, source_position: ASTSourceLocation | None = None) ASTLogicalOperator
- classmethod create_ast_model(name: str, body: ASTModelBody, source_position: ASTSourceLocation, artifact_name: str) ASTModel
- classmethod create_ast_model_body(body_elements: list, source_position: ASTSourceLocation) ASTModelBody
- classmethod create_ast_namespace_decorator(namespace=None, name=None, source_position=None)
- classmethod create_ast_nestml_compilation_unit(list_of_models, source_position: ASTSourceLocation, artifact_name: str) ASTNestMLCompilationUnit
- classmethod create_ast_ode_equation(lhs: ASTVariable, rhs: ASTSimpleExpression | ASTExpression, source_position: ASTSourceLocation, decorators: List | None = None) ASTOdeEquation
- classmethod create_ast_on_condition_block(block=None, cond_expr=None, const_parameters=None, source_position=None)
- classmethod create_ast_on_receive_block(input_port_variable: ASTInputPort, block=None, const_parameters=None, source_position=None)
- classmethod create_ast_output_block(s_type: PortSignalType, source_position: ASTSourceLocation | None = None) ASTOutputBlock
- classmethod create_ast_parameter(name: str, data_type: ASTDataType, source_position: ASTSourceLocation) ASTParameter
- classmethod create_ast_return_stmt(expression: ASTSimpleExpression | ASTExpression = None, source_position: ASTSourceLocation = None) ASTReturnStmt
- classmethod create_ast_simple_expression(function_call: Union(ASTFunctionCall, None) = None, boolean_literal: Union(bool, None) = None, numeric_literal: Union(float, int) = None, is_inf: bool = False, variable: ASTVariable = None, string: Union(str, None) = None, source_position: ASTSourceLocation = None) ASTSimpleExpression
- classmethod create_ast_small_stmt(assignment: ASTAssignment | None = None, function_call: ASTFunctionCall | None = None, declaration: ASTDeclaration | None = None, return_stmt: ASTReturnStmt | None = None, source_position: ASTSourceLocation | None = None) ASTSmallStmt
- classmethod create_ast_stmt(small_stmt: ASTSmallStmt | None = None, compound_stmt: ASTCompoundStmt | None = None, source_position: ASTSourceLocation | None = None) ASTStmt
- classmethod create_ast_stmts_body(stmts: list(ASTSmallStmt | ASTCompoundStmt), source_position: ASTSourceLocation) ASTStmtsBody
- classmethod create_ast_ternary_expression(condition: Union(ASTSimpleExpression, ASTExpression), if_true: Union(ASTSimpleExpression, ASTExpression), if_not: Union(ASTSimpleExpression, ASTExpression), source_position: ASTSourceLocation) ASTExpression
The factory method used to create a ternary operator rhs, e.g., 10mV<V_m?10mV:V_m
- classmethod create_ast_unary_operator(is_unary_plus: bool = False, is_unary_minus: bool = False, is_unary_tilde: bool = False, source_position: ASTSourceLocation | None = None) ASTUnaryOperator
- classmethod create_ast_unit_type(is_encapsulated: bool = False, compound_unit: ASTUnitType | None = None, base: ASTUnitType | None = None, is_pow: bool = False, exponent: int | float | None = None, exponent_num: int | None = None, exponent_den: int | None = None, lhs: ASTUnitType | int | None = None, rhs: ASTUnitType | int | None = None, is_div: bool = False, is_times: bool = False, unit: str | None = None, source_position: ASTSourceLocation | None = None) ASTUnitType
- classmethod create_ast_update_block(block: ASTStmtsBody, source_position: ASTSourceLocation) ASTUpdateBlock
- classmethod create_ast_variable(name: str, differential_order: int = 0, vector_parameter=None, is_homogeneous=False, source_position: ASTSourceLocation | None = None, scope: Scope | None = None) ASTVariable
- classmethod create_ast_while_stmt(condition: Union(ASTSimpleExpression, ASTExpression), block: ASTStmtsBody, source_position: ASTSourceLocation) ASTWhileStmt
pynestml.meta_model.ast_ode_equation module
- class pynestml.meta_model.ast_ode_equation.ASTOdeEquation(lhs, rhs, decorators=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store meta_model equations, e.g., V_m’ = 10mV + V_m. ASTOdeEquation Represents an equation, e.g. “I = exp(t)” or represents an differential equations,
e.g. “V_m’ = V_m+1”.
@attribute lhs Left hand side, e.g. a Variable. @attribute rhs Expression defining the right hand side. Grammar:
odeEquation : lhs=variable “=” rhs=rhs;
- lhs = None
- rhs = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_decorators()
- get_lhs()
Returns the left-hand side of the equation. :return: an object of the meta_model-variable class. :rtype: ASTVariable
- get_rhs()
Returns the left-hand side of the equation. :return: an object of the meta_model-expr class. :rtype: Union[ASTExpression, ASTSimpleExpression]
pynestml.meta_model.ast_on_condition_block module
- class pynestml.meta_model.ast_on_condition_block.ASTOnConditionBlock(stmts_body: ASTStmtsBody, cond_expr: ASTExpression, const_parameters: Mapping | None = None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a declaration of an onCondition block
- clone() ASTOnConditionBlock
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_const_parameters()
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the body of statements
pynestml.meta_model.ast_on_receive_block module
- class pynestml.meta_model.ast_on_receive_block.ASTOnReceiveBlock(input_port_variable: ASTVariable, stmts_body: ASTStmtsBody, const_parameters: Mapping | None = None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a declaration of an onReceive block.
- clone() ASTOnReceiveBlock
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_const_parameters()
- get_input_port_variable() ASTVariable
Returns the port. :return: the port
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the body of statements
pynestml.meta_model.ast_output_block module
- class pynestml.meta_model.ast_output_block.ASTOutputBlock(o_type, *args, **kwargs)
Bases:
ASTNodeThis class is used to store output port declarations. ASTOutput represents the output block of the neuron:
- output:
spike
@attribute spike true if and only if the neuron has a spike output. @attribute continuous true if and only if the neuron has a continuous time output.
- Grammar:
outputBlock: “output” BLOCK_OPEN (“spike” | “continuous”) ;
- type = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
pynestml.meta_model.ast_parameter module
- class pynestml.meta_model.ast_parameter.ASTParameter(name: str, data_type: ASTDataType, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single function parameter definition.
- Grammar:
parameter : NAME datatype;
- data_type
The data type of the parameter.
- Type:
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_data_type()
Returns the data type of the parameter. :return: the data type of the parameter. :rtype: ASTDataType
- get_name()
Returns the name of the parameter. :return: the name of the parameter. :rtype: str
pynestml.meta_model.ast_return_stmt module
- class pynestml.meta_model.ast_return_stmt.ASTReturnStmt(expression=None, *args, **kwargs)
Bases:
ASTNode- This class is used to store a return statement.
A ReturnStmt Models the return statement in a function. @attribute minus An optional sing @attribute definingVariable Name of the variable Grammar:
returnStmt : “return” expr?;
- expression
An rhs representing the returned value.
- Type:
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_expression()
Returns the rhs. :return: an rhs. :rtype: ASTExpression
- has_expression()
Returns whether the return statement has an rhs or not. :return: True if has rhs, otherwise False. :rtype: bool
pynestml.meta_model.ast_simple_expression module
- class pynestml.meta_model.ast_simple_expression.ASTSimpleExpression(function_call: ASTFunctionCall | None = None, boolean_literal: bool | None = None, numeric_literal: int | float | None = None, is_inf: bool = False, variable: ASTVariable | None = None, string: str | None = None, has_delay: bool = False, *args, **kwargs)
Bases:
ASTExpressionNodeThis class is used to store a simple rhs, e.g. +42mV. ASTSimpleExpression, consisting of a single element without combining operator, e.g.,10mV, inf, V_m. Grammar: simpleExpression : functionCall
BOOLEAN_LITERAL // true & false ;(UNSIGNED_INTEGER | FLOAT) (variable)?isInf=”inf”STRING_LITERALvariable;- function_call
A function call reference.
- numeric_literal
A numeric literal.
- variable
A variable reference.
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_boolean_literal() bool | None
Returns boolean literal if available, otherwise None. :return: boolean literal if ASTSimpleExpression is boolean literal, otherwise None
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_function_call()
Returns the function call object. :return: the function call object. :rtype: ASTFunctionCall
- get_function_calls()
This function is used for better interactions with the general rhs meta_model class. :return: returns a single list with this function call if such an exists, otherwise an empty list :rtype: list(ASTFunctionCall)
- get_has_delay()
Returns the has_delay parameter :return: returns the value of has_delay parameter
- get_numeric_literal() int | float
Returns the value of the numeric literal. :return: the value of the numeric literal. :rtype: int/float
- get_string()
Returns the string as stored in this simple rhs. :return: a string as stored in this rhs. :rtype: str
- get_units()
This function is used for better interactions with the general rhs meta_model class. :return: returns a single list with unit if such an exists, otherwise an empty list :rtype: list(ASTVariable)
- get_variable()
Returns the variable. :return: the variable object. :rtype: ASTVariable
- get_variables()
This function is used for better interactions with the general rhs meta_model class. :return: returns a single list with this variable if such an exists, otherwise an empty list :rtype: list(ASTVariable)
- has_unit()
Returns whether this is a numeric literal with a defined unit. :return: True if numeric literal with unit, otherwise False. :rtype: bool
- is_delay_variable()
Returns whether it is a delay variable or not :return: True if the variable has a delay parameter, False otherwise
- is_function_call()
Returns whether it is a function call or not. :return: True if function call, otherwise False. :rtype: bool
- is_numeric_literal()
Returns whether it is a numeric literal or not. :return: True if numeric literal, otherwise False. :rtype: bool
- is_string()
Returns whether this simple rhs is a string. :return: True if string, False otherwise. :rtype: bool
- is_variable()
Returns whether it is a variable or not. :return: True if has a variable, otherwise False. :rtype: bool
- set_function_call(function_call)
Updates the function call of this node. :param function_call: a single function call :type function_call: Union(ASTFunctionCall,None)
- set_numeric_literal(numeric_literal)
Updates the numeric literal attribute of this node. :param numeric_literal: a single numeric literal :type numeric_literal: int or float
- set_variable(variable)
Updates the variable of this node. :param variable: a single variable :type variable: ASTVariable
pynestml.meta_model.ast_small_stmt module
- class pynestml.meta_model.ast_small_stmt.ASTSmallStmt(assignment=None, function_call=None, declaration=None, return_stmt=None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store small statements, e.g., a declaration. Grammar:
- smallStmtassignment
- functionCalldeclarationreturnStmt;
- assignment
A assignment reference.
- Type:
ast_assignment
- function_call
A function call reference.
- Type:
ast_function_call
- declaration
A declaration reference.
- Type:
ast_declaration
- return_stmt
A reference to the returns statement.
- Type:
ast_return_stmt
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_assignment()
Returns the assignment. :return: the assignment statement. :rtype: ast_assignment
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_declaration()
Returns the assignment. :return: the declaration statement. :rtype: ast_declaration
- get_function_call()
Returns the function call. :return: the function call statement. :rtype: ast_function_call
- get_return_stmt()
Returns the return statement. :return: the return statement. :rtype: ast_return_stmt
- is_assignment()
Returns whether it is an assignment statement or not. :return: True if assignment, False else. :rtype: bool
- is_declaration()
Returns whether it is a declaration statement or not. :return: True if declaration, False else. :rtype: bool
- is_function_call()
Returns whether it is an function call or not. :return: True if function call, False else. :rtype: bool
- is_return_stmt()
Returns whether it is a return statement or not. :return: True if return stmt, False else. :rtype: bool
pynestml.meta_model.ast_stmt module
- class pynestml.meta_model.ast_stmt.ASTStmt(small_stmt, compound_stmt, *args, **kwargs)
Bases:
ASTNodeStores a reference to either small or compound statement. Grammar:
stmt : smallStmt | compoundStmt;
- small_stmt = None
- compound_stmt = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- is_compound_stmt()
- is_small_stmt()
pynestml.meta_model.ast_stmts_body module
- class pynestml.meta_model.ast_stmts_body.ASTStmtsBody(stmts, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single block of declarations, i.e., statements. Grammar:
block : ( smallStmt | compoundStmt | NEWLINE )*;
- Attribute:
stmts = None
- add_stmt(stmt)
Adds a single statement to the list of statements. :param stmt: a statement :type stmt: ASTSmallStmt,ASTCompoundStmt
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
ASTBlock
- delete_stmt(stmt)
Deletes the handed over statement. :param stmt: :type stmt: :return: True if deleted, otherwise False. :rtype: bool
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_stmts()
Returns the list of statements. :return: list of stmts. :rtype: list(ASTSmallStmt/ASTCompoundStmt)
pynestml.meta_model.ast_unary_operator module
- class pynestml.meta_model.ast_unary_operator.ASTUnaryOperator(is_unary_plus=False, is_unary_minus=False, is_unary_tilde=False, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single unary operator, e.g., ~. Grammar:
unaryOperator : (unaryPlus=”+” | unaryMinus=”-” | unaryTilde=”~”);
- is_unary_plus = False
- is_unary_minus = False
- is_unary_tilde = False
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
pynestml.meta_model.ast_unit_type module
- class pynestml.meta_model.ast_unit_type.ASTUnitType(is_encapsulated: bool = False, compound_unit: ASTUnitType | None = None, base: ASTUnitType | None = None, is_pow: bool = False, exponent: int | float | None = None, exponent_num: float | None = None, exponent_den: float | None = None, lhs: ASTUnitType | int | None = None, rhs: ASTUnitType | None = None, is_div: bool = False, is_times: bool = False, _unit: str | None = None, type_symbol: TypeSymbol | None = None, *args, **kwargs)
Bases:
ASTNodeThis class stores information regarding unit types and their properties. ASTUnitType. Represents an unit datatype. It can be a plain datatype as “mV” or a complex data type as “mV/s”
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_lhs()
Returns the left-hand side rhs if present. :return: ASTUnitType instance if present, otherwise None. :rtype: ASTUnitType
- get_rhs()
Returns the right-hand side rhs if present. :return: ASTUnitType instance if present, otherwise None. :rtype: ASTUnitType
- get_type_symbol()
- is_arithmetic_expression()
Returns whether the rhs is a arithmetic combination, e.g, mV/mS. :return: True if arithmetic rhs, otherwise false. :rtype: bool
- is_simple_unit()
Returns whether the rhs is a simple unit, e.g., mV. :return: True if simple unit, otherwise False. :rtype: bool
- set_type_symbol(type_symbol)
pynestml.meta_model.ast_update_block module
- class pynestml.meta_model.ast_update_block.ASTUpdateBlock(stmts_body: ASTStmtsBody, *args, **kwargs)
Bases:
ASTNodeThe
updateblock in the model.- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the statements body
pynestml.meta_model.ast_variable module
- class pynestml.meta_model.ast_variable.ASTVariable(name, differential_order=0, type_symbol: str | None = None, vector_parameter: str | ASTParameter | None = None, is_homogeneous: bool = False, delay_parameter: str | None = None, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a single variable.
ASTVariable Provides a “marker” AST node to identify variables used in expressions. Grammar:
variable : NAME (differentialOrder=”’”)*;
- name = None
- differential_order = None
- # the corresponding type symbol
- type_symbol = None
- clone()
Return a clone (“deep copy”) of this node.
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_complete_name() str
Returns the complete name, consisting of the name and the differential order. :return: the complete name.
- get_delay_parameter()
Returns the delay parameter :return: delay parameter
- get_differential_order() int
Returns the differential order of the variable. :return: the differential order.
- get_name_of_lhs() str
Returns the complete name but with differential order reduced by one. :return: the name.
- get_type_symbol() TypeSymbol
Returns the type symbol of this rhs. :return: a single type symbol.
- get_vector_parameter() str
Returns the vector parameter of the variable :return: the vector parameter
- has_vector_parameter() bool
Returns the vector parameter of the variable :return: the vector parameter
- is_delay_variable() bool
Returns whether it is a delay variable or not :return: True if the variable has a delay parameter, False otherwise
- is_unit_variable() bool
Provided on-the-fly information whether this variable represents a unit-variable, e.g., nS. Caution: It assumes that the symbol table has already been constructed. :return: True if unit-variable, otherwise False.
- resolve_in_own_scope()
- set_delay_parameter(delay: str)
Updates the current delay parameter to the handed over value :param delay: delay parameter
- set_differential_order(differential_order: int) None
Returns the differential order of the variable.
- set_type_symbol(type_symbol: TypeSymbol)
Updates the current type symbol to the handed over one. :param type_symbol: a single type symbol object.
- set_vector_parameter(vector_parameter)
Updates the vector parameter of the variable
pynestml.meta_model.ast_while_stmt module
- class pynestml.meta_model.ast_while_stmt.ASTWhileStmt(condition: ASTExpression, stmts_body: ASTStmtsBody, *args, **kwargs)
Bases:
ASTNodeThis class is used to store a new while-block. Grammar:
whileStmt : “while” expr BLOCK_OPEN block BLOCK_CLOSE;
- condition = None
- block = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns:
new AST node instance
- Return type:
- get_children() List[ASTNode]
Returns the children of this node, if any. :return: List of children of this node.
- get_condition()
Returns the condition of the block. :return: the condition. :rtype: ASTExpression
- get_stmts_body() ASTStmtsBody
Returns the body of statements. :return: the body of statements.