diff --git a/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronClass.jinja2 b/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronClass.jinja2 index 7f20b6b66..35c86d69b 100644 --- a/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronClass.jinja2 +++ b/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronClass.jinja2 @@ -570,7 +570,7 @@ void {{neuronName}}::pre_run_hook() {%- include "directives_cpp/GSLDifferentiationFunction.jinja2" %} {%- endfor %} -{%- if paired_synapse is defined %} +{%- if paired_synapse is defined and (purely_numeric_state_variables_moved + analytic_state_variables_moved) | length > 0 %} {# for neuron-synapse co-generation: separate integrator for the emulated integrate_odes() calls below in this template #} {%- set args = utils.resolve_variables_to_expressions(astnode, purely_numeric_state_variables_moved + analytic_state_variables_moved) %} {%- set ast = ASTNodeFactory.create_ast_function_call("integrate_odes", args) %} diff --git a/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronHeader.jinja2 b/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronHeader.jinja2 index 9f25f629e..4be445ce2 100644 --- a/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronHeader.jinja2 +++ b/pynestml/codegeneration/resources_nest/point_neuron/common/NeuronHeader.jinja2 @@ -120,9 +120,9 @@ namespace {{names_namespace}} } -{% if uses_numeric_solver %} +{% if uses_numeric_solver %} -{%- for s in utils.create_integrate_odes_combinations(astnode) %} +{%- for s in utils.create_integrate_odes_combinations(astnode) %} /** * Function computing right-hand side of ODE for GSL solver. * @note Must be declared here so we can befriend it in class. @@ -136,9 +136,9 @@ namespace {{names_namespace}} * Integrate the variables: {{ s }} **/ extern "C" inline int {{neuronName}}_dynamics{% if s | length > 0 %}_{{ s }}{% endif %}( double, const double ode_state[], double f[], void* pnode ); -{%- endfor %} +{%- endfor %} -{%- if paired_synapse is defined %} +{%- if paired_synapse is defined and (purely_numeric_state_variables_moved + analytic_state_variables_moved) | length > 0 %} {# for neuron-synapse co-generation: separate integrator for the emulated/dummy integrate_odes() below in NeuronClass.jinja2 #} {%- set args = utils.resolve_variables_to_expressions(astnode, purely_numeric_state_variables_moved + analytic_state_variables_moved) %} {%- set ast = ASTNodeFactory.create_ast_function_call("integrate_odes", args) %} diff --git a/pynestml/utils/ast_utils.py b/pynestml/utils/ast_utils.py index e9ae0daa0..9b0a372a6 100644 --- a/pynestml/utils/ast_utils.py +++ b/pynestml/utils/ast_utils.py @@ -1871,10 +1871,10 @@ def _visit(self, node): model.integrate_odes_combinations = visitor.all_args # always ensure code is generated for an integrate_odes() call without any arguments. This is needed, for example, for gap junctions support - if not [] in model.integrate_odes_combinations: - model.integrate_odes_combinations.append([]) + if not "" in model.integrate_odes_combinations: + model.integrate_odes_combinations.append("") - return visitor.all_args + return model.integrate_odes_combinations @classmethod def get_all_integrate_odes_calls_unique(cls, model: ASTModel) -> None: diff --git a/tests/nest_tests/test_co_generation_static_synapse.py b/tests/nest_tests/test_co_generation_static_synapse.py new file mode 100644 index 000000000..c361a9f85 --- /dev/null +++ b/tests/nest_tests/test_co_generation_static_synapse.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# +# test_co_generation_static_synapse.py +# +# This file is part of NEST. +# +# Copyright (C) 2004 The NEST Initiative +# +# NEST is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# NEST is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with NEST. If not, see . + +import os + +from pynestml.codegeneration.nest_tools import NESTTools +from pynestml.frontend.pynestml_frontend import generate_nest_target + +try: + import matplotlib + matplotlib.use("Agg") + import matplotlib.ticker + import matplotlib.pyplot as plt + TEST_PLOTS = True +except Exception: + TEST_PLOTS = False + + +def test_co_generation_static_synapse(): + r"""This tests the case that there is a complex neuron model and a simple synapse model that does not transfer any variables.""" + + files = [os.path.join("models", "neurons", "hill_tononi_neuron.nestml"), + os.path.join("models", "synapses", "static_synapse.nestml")] + input_path = [os.path.realpath(os.path.join(os.path.dirname(__file__), os.path.join( + os.pardir, os.pardir, s))) for s in files] + generate_nest_target(input_path=input_path, + logging_level="INFO", + suffix="_nestml", + codegen_opts={"neuron_synapse_pairs": [{"neuron": "hill_tononi_neuron", + "synapse": "static_synapse"}], + "delay_variable": {"static_synapse": "d"}, + "weight_variable": {"static_synapse": "w"}})