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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other: pynestml.meta_model.ast_node.ASTNode) bool
The equality method.
pynestml.meta_model.ast_assignment module
- class pynestml.meta_model.ast_assignment.ASTAssignment(lhs: Optional[pynestml.meta_model.ast_variable.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, rhs: Optional[pynestml.meta_model.ast_expression.ASTExpression] = None, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This 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)
- deconstruct_compound_assignment()
From lhs and rhs it constructs a new expression which corresponds to direct assignment. E.g.: a += b*c -> a = a + b*c :return: the rhs for an equivalent direct assignment. :rtype: ast_expression
- equals(other)
The equals operation. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- extract_operator_from_compound_assignment()
- get_bracketed_rhs_expression()
- get_expression()
Returns the right-hand side rhs. :return: rhs object. :rtype: ast_expression
- get_lhs_variable_as_expression()
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- 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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
pynestml.meta_model.ast_block module
- class pynestml.meta_model.ast_block.ASTBlock(stmts, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This 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
- delete_stmt(stmt)
Deletes the handed over statement. :param stmt: :type stmt: :return: True if deleted, otherwise False. :rtype: bool
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- get_stmts()
Returns the list of statements. :return: list of stmts. :rtype: list(ASTSmallStmt/ASTCompoundStmt)
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:
pynestml.meta_model.ast_node.ASTNode
This 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]
end
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. attribute AliasDecl: a list with variable declarations 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
- equals(other=None)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False :rtype: bool
- 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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- 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_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- 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
pynestml.meta_model.ast_declaration module
pynestml.meta_model.ast_elif_clause module
- class pynestml.meta_model.ast_elif_clause.ASTElifClause(condition, block, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store elif-clauses. Grammar:
elifClause : ‘elif’ rhs BLOCK_OPEN block;
- Attribute:
condition = None block = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- Return type
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_block()
Returns the block of statements. :return: the block of statements. :rtype: ast_block
- get_condition()
Returns the condition of the block. :return: the condition. :rtype: ast_expression
pynestml.meta_model.ast_else_clause module
- class pynestml.meta_model.ast_else_clause.ASTElseClause(block, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store a single else-clause. Grammar:
elseClause : ‘else’ BLOCK_OPEN block;
- block = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- Return type
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_block()
Returns the block of statements. :return: the block of statements. :rtype: ast_block
pynestml.meta_model.ast_equations_block module
pynestml.meta_model.ast_expression module
- class pynestml.meta_model.ast_expression.ASTExpression(is_encapsulated=False, unary_operator=None, is_logical_not=False, expression=None, lhs=None, binary_operator=None, rhs=None, condition=None, if_true=None, if_not=None, *args, **kwargs)
Bases:
pynestml.meta_model.ast_expression_node.ASTExpressionNode
ASTExpr, 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_binary_operator()
Returns the binary operator. :return: the binary operator. :rtype: one of ASTLogicalOperator,ASTComparisonOperator,ASTBitOperator,ASTArithmeticOperator
- 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_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_parent(ast=None)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- 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:
pynestml.meta_model.ast_node.ASTNode
This 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.
- equals(other)
The equals operation. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- 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:
pynestml.meta_model.ast_variable.ASTVariable
This 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, block, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store a for-block. Grammar:
- forStmt‘for’ var=NAME ‘in’ vrom=rhs
‘…’ to=rhs ‘step’ step=signedNumericLiteral BLOCK_OPEN block BLOCK_CLOSE;
- variable = None
- start_from = None
- end_at = None
- step = None
- block = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- Return type
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_block()
Returns the block of statements. :return: the block of statements. :rtype: ast_block
- get_end_at()
Returns the to-statement. :return: the rhs indicating the finish value. :rtype: ast_expression
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- 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_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, parameters, return_type, block, type_symbol=None, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store a user-defined function. ASTFunction a function definition:
- function set_V_m(v mV):
y3 = v - E_L
end
@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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_block()
Returns the block containing the definitions. :return: the block of the definitions. :rtype: ast_block
- get_name()
Returns the name of the function. :return: the name of the function. :rtype: str
- get_parameters()
Returns the list of parameters. :return: a parameters object containing the list. :rtype: list(ASTParameter)
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- get_return_type()
Returns the return type of function. :return: the return type :rtype: ast_data_type
- get_type_symbol()
Returns the type symbol of this rhs. :return: a single type symbol. :rtype: type_symbol
- has_parameters()
Returns whether parameters have been defined. :return: True if parameters defined, otherwise False. :rtype: bool
- 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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_args()
Returns the list of arguments. :return: the list of arguments. :rtype: list(ASTExpression)
- get_name()
Returns the name of the called function. :return: the name of the function. :rtype: str.
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- 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, block, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store a single if-clause. Grammar:
ifClause : ‘if’ expr BLOCK_OPEN block;
- condition = None
- block = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- Return type
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equals, otherwise False. :rtype: bool
- get_block()
Returns the block of statements. :return: the block of statements. :rtype: ASTBlock
- get_condition()
Returns the condition of the block. :return: the condition. :rtype: ASTExpression
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: ASTNode :return: AST if this or one of the child nodes contains the handed over element. :rtype: Optional[ASTNode]
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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equals, otherwise False. :rtype: bool
- 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
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: ASTNode :return: AST if this or one of the child nodes contains the handed over element. :rtype: Optional[ASTNode]
- 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, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- 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_expression()
Returns the rhs as an object of ASTExpression. :return: the rhs as an object of ASTExpression. :rtype: ast_expression
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- get_variable_name()
Returns the variable name. :return: the name of the variable. :rtype: str
pynestml.meta_model.ast_input_block module
pynestml.meta_model.ast_input_port module
pynestml.meta_model.ast_input_qualifier module
- class pynestml.meta_model.ast_input_qualifier.ASTInputQualifier(is_inhibitory=False, is_excitatory=False, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store the qualifier of a buffer. ASTInputQualifier represents the qualifier of the input port. Only valid for spiking inputs. @attribute inhibitory true Indicates that this spiking input port is inhibitory. @attribute excitatory true Indicates that this spiking input port is excitatory.
- Grammar:
inputQualifier : (‘inhibitory’ | ‘excitatory’);
- is_inhibitory = False
- is_excitatory = False
- clone()
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- Return type
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: ASTNode :return: AST if this or one of the child nodes contains the handed over element. :rtype: Optional[ASTNode]
pynestml.meta_model.ast_kernel module
- class pynestml.meta_model.ast_kernel.ASTKernel(variables, expressions, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This 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
ASTInputPort
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_expressions()
Returns the right-hand side rhs. :return: the rhs :rtype: ast_expression
- get_parent(ast)
Indicates whether this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: ASTNode :return: AST if this or one of the child nodes contains the handed over element. :rtype: ASTNode or None
- 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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
pynestml.meta_model.ast_namespace_decorator module
- class pynestml.meta_model.ast_namespace_decorator.ASTNamespaceDecorator(namespace=None, name=None, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
- clone()
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- Return type
- equals(other)
The equals operation. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_name()
Returns the right-hand side rhs. :return: rhs object. :rtype: ast_expression
- get_namespace()
Returns the left-hand side variable. :return: left-hand side variable object. :rtype: ASTVariable
pynestml.meta_model.ast_nestml_compilation_unit module
pynestml.meta_model.ast_neuron module
pynestml.meta_model.ast_neuron_or_synapse module
pynestml.meta_model.ast_neuron_or_synapse_body module
pynestml.meta_model.ast_node module
- class pynestml.meta_model.ast_node.ASTNode(source_position=None, scope=None, comment=None, pre_comments=None, in_comment=None, post_comments=None, implicit_conversion_factor=None)
Bases:
object
This 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
- post_comments = list()
- #
- 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)
The equals operation. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_comment()
Returns the comment of this element. :return: a comment. :rtype: str
- get_comments()
- get_implicit_conversion_factor()
Returns the factor installed as implicitConversionFactor for this expression :return: the conversion factor, if present, or None :rtype: Optional[float]
- abstract get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- get_post_comments()
- 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 prefix. :return: True if has comment, otherwise False. :rtype: bool
- print_comment(prefix)
Prints the comment of this meta_model element. :param prefix: a prefix string :type prefix: str :return: a comment :rtype: str
- set_comment(comment)
Updates the comment of this element. :param comment: a comment :type comment: str
- set_implicit_conversion_factor(implicit_factor)
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 :type implicit_factor: Optional[float] :return: nothing
- 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
pynestml.meta_model.ast_ode_equation module
pynestml.meta_model.ast_on_receive_block module
- class pynestml.meta_model.ast_on_receive_block.ASTOnReceiveBlock(block: pynestml.meta_model.ast_block.ASTBlock, port_name: str, const_parameters: Optional[Mapping] = None, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store a declaration of an onReceive block, for example:
onReceive(pre_spikes): pre_tr += 1 end
- clone() pynestml.meta_model.ast_on_receive_block.ASTOnReceiveBlock
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- equals(other: Any) bool
The equals method. :param other: a different object. :return: True if equal, otherwise False.
- get_block() pynestml.meta_model.ast_block.ASTBlock
Returns the block of definitions. :return: the block
- get_const_parameters()
- get_parent(ast: pynestml.meta_model.ast_node.ASTNode) Optional[pynestml.meta_model.ast_node.ASTNode]
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :return: AST if this or one of the child nodes contains the handed over element.
pynestml.meta_model.ast_output_block module
- class pynestml.meta_model.ast_output_block.ASTOutputBlock(o_type, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other) bool
The equals method. :param other: a different object. :type other: object :return: True if equals, otherwise False.
- get_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
pynestml.meta_model.ast_parameter module
pynestml.meta_model.ast_return_stmt module
pynestml.meta_model.ast_simple_expression module
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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object :type other: object :return: True if equals, otherwise False. :rtype: bool
- get_assignment()
Returns the assignment. :return: the assignment statement. :rtype: ast_assignment
- 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_parent(ast)
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :type ast: AST_ :return: AST if this or one of the child nodes contains the handed over element. :rtype: AST_ or None
- 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:
pynestml.meta_model.ast_node.ASTNode
Stores 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
- equals(other=None)
The equals operation. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_parent(ast: Optional[pynestml.meta_model.ast_node.ASTNode] = None) Optional[pynestml.meta_model.ast_node.ASTNode]
Returns the parent node of a handed over AST object.
- is_compound_stmt()
- is_small_stmt()
pynestml.meta_model.ast_synapse module
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:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
pynestml.meta_model.ast_unit_type module
pynestml.meta_model.ast_update_block module
- class pynestml.meta_model.ast_update_block.ASTUpdateBlock(block, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This class is used to store dynamic blocks. ASTUpdateBlock is a special function definition:
- update:
- if r == 0: # not refractory
integrate(V)
end
end
@attribute block Implementation of the dynamics.
- Grammar:
- updateBlock:
‘update’ BLOCK_OPEN
block
BLOCK_CLOSE;
- block = None
- clone()
Return a clone (“deep copy”) of this node.
- Returns
new AST node instance
- Return type
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equal, otherwise False. :rtype: bool
- get_block()
Returns the block of definitions. :return: the block :rtype: ASTBlock
pynestml.meta_model.ast_variable module
- class pynestml.meta_model.ast_variable.ASTVariable(name, differential_order=0, type_symbol: Optional[str] = None, vector_parameter: Optional[str] = None, is_homogeneous: bool = False, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This 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.
- equals(other: Any) bool
The equals method. :param other: a different object. :return: True if equals, otherwise False.
- get_complete_name() str
Returns the complete name, consisting of the name and the differential order. :return: the complete name.
- 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_parent(ast: pynestml.meta_model.ast_node.ASTNode) Optional[pynestml.meta_model.ast_node.ASTNode]
Indicates whether a this node contains the handed over node. :param ast: an arbitrary meta_model node. :return: AST if this or one of the child nodes contains the handed over element.
- get_type_symbol() pynestml.symbols.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
- 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_differential_order(differential_order: int) None
Returns the differential order of the variable.
- set_size_parameter(vector_parameter)
Updates the vector parameter of the variable
- set_type_symbol(type_symbol: pynestml.symbols.type_symbol.TypeSymbol)
Updates the current type symbol to the handed over one. :param type_symbol: a single type symbol object.
pynestml.meta_model.ast_while_stmt module
- class pynestml.meta_model.ast_while_stmt.ASTWhileStmt(condition: pynestml.meta_model.ast_expression.ASTExpression, block: pynestml.meta_model.ast_block.ASTBlock, *args, **kwargs)
Bases:
pynestml.meta_model.ast_node.ASTNode
This 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
- equals(other)
The equals method. :param other: a different object. :type other: object :return: True if equals, otherwise False. :rtype: bool
- get_block()
Returns the block of statements. :return: the block of statements. :rtype: ASTBlock
- get_condition()
Returns the condition of the block. :return: the condition. :rtype: ASTExpression