Skip to content

Commit

Permalink
fix third-factor plasticity buffering and add third factor plasticity…
Browse files Browse the repository at this point in the history
… tutorial
  • Loading branch information
C.A.P. Linssen committed Jun 18, 2024
1 parent 4f937be commit 6d81daf
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 190 deletions.

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pynestml/codegeneration/printers/nest_variable_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ def print_variable(self, variable: ASTVariable) -> str:
if isinstance(variable, ASTExternalVariable):
_name = str(variable)
if variable.get_alternate_name():
if not variable._altscope:
# get the value from the postsynaptic partner continuous-time buffer (for post_connected_continuous_input_ports); this has been buffered in a local temp variable starting with "__"
return variable.get_alternate_name()

# get the value from the postsynaptic partner (without time specified)
# the disadvantage of this approach is that the time the value is to be obtained is not explicitly specified, so we will actually get the value at the end of the min_delay timestep
return "((post_neuron_t*)(__target))->get_" + variable.get_alternate_name() + "()"

# get the value from the postsynaptic partner (with time specified)
return "((post_neuron_t*)(__target))->get_" + _name + "(_tr_t)"

if variable.get_name() == PredefinedVariables.E_CONSTANT:
Expand Down
2 changes: 1 addition & 1 deletion pynestml/transformers/synapse_post_neuron_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def mark_post_port(_expr=None):

for state_var, alternate_name in zip(post_connected_continuous_input_ports, post_variable_names):
Logger.log_message(None, -1, "\t• Replacing variable " + str(state_var), None, LoggingLevel.INFO)
ASTUtils.replace_with_external_variable(state_var, new_synapse, "", new_synapse.get_equations_blocks()[0].get_scope(), alternate_name)
ASTUtils.replace_with_external_variable(state_var, new_synapse, "", None, "__" + state_var)

#
# copy parameters
Expand Down
2 changes: 1 addition & 1 deletion pynestml/utils/ast_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def get_var_name_tuples_of_neuron_synapse_pair(cls, post_port_names, post_port):
return None

@classmethod
def replace_with_external_variable(cls, var_name, node: ASTNode, suffix, new_scope, alternate_name=None):
def replace_with_external_variable(cls, var_name, node: ASTNode, suffix: str, new_scope, alternate_name=None):
r"""
Replace all occurrences of variables (``ASTVariable``s) (e.g. ``post_trace'``) in the node with ``ASTExternalVariable``s, indicating that they are moved to the postsynaptic neuron.
"""
Expand Down

0 comments on commit 6d81daf

Please sign in to comment.