Skip to content

Commit cf274da

Browse files
authored
add NESTML version to generated code (#1164)
1 parent b786d5f commit cf274da

20 files changed

+29
-21
lines changed

Diff for: pynestml/codegeneration/nest_code_generator.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,13 @@ def _get_module_namespace(self, neurons: List[ASTModel], synapses: List[ASTModel
301301
namespace = {"neurons": neurons,
302302
"synapses": synapses,
303303
"moduleName": FrontendConfiguration.get_module_name(),
304+
"nestml_version": pynestml.__version__,
304305
"now": datetime.datetime.utcnow()}
306+
305307
# NEST version
306308
if self.option_exists("nest_version"):
307309
namespace["nest_version"] = self.get_option("nest_version")
310+
308311
return namespace
309312

310313
def analyse_transform_neurons(self, neurons: List[ASTModel]) -> None:
@@ -469,9 +472,9 @@ def analyse_synapse(self, synapse: ASTModel) -> Dict[str, ASTAssignment]:
469472
return spike_updates
470473

471474
def _get_model_namespace(self, astnode: ASTModel) -> Dict:
472-
473475
namespace = {}
474476

477+
namespace["nestml_version"] = pynestml.__version__
475478
namespace["now"] = datetime.datetime.utcnow()
476479
namespace["tracing"] = FrontendConfiguration.is_dev
477480

Diff for: pynestml/codegeneration/nest_compartmental_code_generator.py

+2
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def _get_module_namespace(self, neurons: List[ASTModel]) -> Dict:
240240
namespace = {"neurons": neurons,
241241
"nest_version": self.get_option("nest_version"),
242242
"moduleName": FrontendConfiguration.get_module_name(),
243+
"nestml_version": pynestml.__version__,
243244
"now": datetime.datetime.utcnow()}
244245

245246
# auto-detect NEST Simulator installed version
@@ -577,6 +578,7 @@ def _get_neuron_model_namespace(self, neuron: ASTModel) -> Dict:
577578

578579
namespace = {}
579580

581+
namespace["nestml_version"] = pynestml.__version__
580582
namespace["now"] = datetime.datetime.utcnow()
581583
namespace["tracing"] = FrontendConfiguration.is_dev
582584

Diff for: pynestml/codegeneration/nest_desktop_code_generator.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from typing import Sequence, Optional, Mapping, Any, Dict
2323

24+
import pynestml
2425
from pynestml.codegeneration.code_generator import CodeGenerator
2526
from pynestml.codegeneration.code_generator_utils import CodeGeneratorUtils
2627
from pynestml.meta_model.ast_model import ASTModel
@@ -64,6 +65,7 @@ def _get_neuron_model_namespace(self, neuron: ASTModel) -> Dict:
6465
from pynestml.codegeneration.nest_tools import NESTTools
6566

6667
namespace = dict()
68+
namespace["nestml_version"] = pynestml.__version__
6769
namespace["neuronName"] = neuron.get_name()
6870
namespace["neuron"] = neuron
6971
namespace["parameters"] = NESTTools.get_neuron_parameters(neuron.get_name())

Diff for: pynestml/codegeneration/resources_nest/point_neuron/common/NeuronClass.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ along with NEST. If not, see <http://www.gnu.org/licenses/>.
4545
* You should have received a copy of the GNU General Public License
4646
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4747
*
48-
* Generated from NESTML at time: {{now}}
48+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4949
**/
5050

5151
// C++ includes:

Diff for: pynestml/codegeneration/resources_nest/point_neuron/common/NeuronHeader.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ along with NEST. If not, see <http://www.gnu.org/licenses/>.
4545
* You should have received a copy of the GNU General Public License
4646
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4747
*
48-
* Generated from NESTML at time: {{now}}
48+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4949
**/
5050
#ifndef {{neuronName.upper()}}
5151
#define {{neuronName.upper()}}

Diff for: pynestml/codegeneration/resources_nest/point_neuron/common/SynapseHeader.h.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ along with NEST. If not, see <http://www.gnu.org/licenses/>.
4040
* You should have received a copy of the GNU General Public License
4141
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4242
*
43-
* Generated from NESTML at time: {{now}}
43+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4444
**/
4545

4646
#ifndef {{synapseName.upper()}}_H

Diff for: pynestml/codegeneration/resources_nest/point_neuron/setup/common/ModuleClass.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* You should have received a copy of the GNU General Public License
4141
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4242
*
43-
* {{now}}
43+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4444
*/
4545

4646
// Includes from nestkernel:

Diff for: pynestml/codegeneration/resources_nest/point_neuron/setup/common/ModuleClassMaster.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* You should have received a copy of the GNU General Public License
4141
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4242
*
43-
* {{now}}
43+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4444
*/
4545

4646
// Include from NEST

Diff for: pynestml/codegeneration/resources_nest/point_neuron/setup/common/ModuleHeader.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* You should have received a copy of the GNU General Public License
4141
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4242
*
43-
* {{now}}
43+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4444
*/
4545

4646
#ifndef {{upperModuleName}}_H

Diff for: pynestml/codegeneration/resources_nest_compartmental/cm_neuron/setup/common/ModuleClass.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* You should have received a copy of the GNU General Public License
4141
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4242
*
43-
* {{now}}
43+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4444
*/
4545

4646
// Includes from nestkernel:

Diff for: pynestml/codegeneration/resources_nest_compartmental/cm_neuron/setup/common/ModuleClassMaster.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* You should have received a copy of the GNU General Public License
4141
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4242
*
43-
* {{now}}
43+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4444
*/
4545

4646
// Include from NEST

Diff for: pynestml/codegeneration/resources_nest_compartmental/cm_neuron/setup/common/ModuleHeader.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* You should have received a copy of the GNU General Public License
4141
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
4242
*
43-
* {{now}}
43+
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
4444
*/
4545

4646
#ifndef {{upperModuleName}}_H

Diff for: pynestml/codegeneration/resources_python_standalone/point_neuron/@[email protected]

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GNU General Public License for more details.
3939
You should have received a copy of the GNU General Public License
4040
along with NEST. If not, see <http://www.gnu.org/licenses/>.
4141

42-
Generated from NESTML at time: {{now}}
42+
Generated from NESTML {{ nestml_version }} at time: {{ now }}
4343
"""
4444

4545
{% if tracing %}# generated by {{self._TemplateReference__context.name}}

Diff for: pynestml/codegeneration/resources_python_standalone/point_neuron/@[email protected]

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GNU General Public License for more details.
3939
You should have received a copy of the GNU General Public License
4040
along with NEST. If not, see <http://www.gnu.org/licenses/>.
4141

42-
Generated from NESTML at time: {{now}}
42+
Generated from NESTML {{ nestml_version }} at time: {{ now }}
4343
"""
4444

4545
{% if tracing %}# generated by {{self._TemplateReference__context.name}}

Diff for: pynestml/codegeneration/resources_python_standalone/point_neuron/neuron.py.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ GNU General Public License for more details.
1818
You should have received a copy of the GNU General Public License
1919
along with NEST. If not, see <http://www.gnu.org/licenses/>.
2020

21-
Generated from NESTML at time: {{now}}
21+
Generated from NESTML {{ nestml_version }} at time: {{ now }}
2222
"""
2323

2424
from typing import List

Diff for: pynestml/codegeneration/resources_python_standalone/point_neuron/simulator.py.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GNU General Public License for more details.
3939
You should have received a copy of the GNU General Public License
4040
along with NEST. If not, see <http://www.gnu.org/licenses/>.
4141

42-
Generated from NESTML at time: {{now}}
42+
Generated from NESTML {{ nestml_version }} at time: {{ now }}
4343
"""
4444

4545
from typing import List, Mapping, Optional, Union

Diff for: pynestml/codegeneration/resources_python_standalone/point_neuron/spike_generator.py.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ GNU General Public License for more details.
1818
You should have received a copy of the GNU General Public License
1919
along with NEST. If not, see <http://www.gnu.org/licenses/>.
2020

21-
Generated from NESTML at time: {{now}}
21+
Generated from NESTML {{ nestml_version }} at time: {{ now }}
2222
"""
2323

2424
from .neuron import Neuron

Diff for: pynestml/codegeneration/resources_python_standalone/point_neuron/synapse.py.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ GNU General Public License for more details.
1818
You should have received a copy of the GNU General Public License
1919
along with NEST. If not, see <http://www.gnu.org/licenses/>.
2020

21-
Generated from NESTML at time: {{now}}
21+
Generated from NESTML {{ nestml_version }} at time: {{ now }}
2222
"""
2323

2424
from typing import List

Diff for: pynestml/codegeneration/resources_spinnaker/@[email protected]

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
# You should have received a copy of the GNU General Public License
1919
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2020
#
21-
# Generated from NESTML at time: {{now}}
21+
# Generated from NESTML {{ nestml_version }} at time: {{ now }}
22+
2223
from numpy import exp, ceil
2324

2425
from spynnaker.pyNN.models.neuron import AbstractPyNNNeuronModel
@@ -54,15 +55,15 @@ class {{neuronName}}(AbstractPyNNNeuronModel):
5455

5556
{%- for variable_symbol in neuron.get_spike_input_ports() %}
5657
{%- if variable_symbol.get_initial_value() == None %}
57-
{{variable_symbol.get_symbol_name()}} = 0.0,
58+
{{variable_symbol.get_symbol_name()}} = 0.0,
5859
{%- else %}
5960
{{variable_symbol.get_symbol_name()}} = {{variable_symbol.get_initial_value()}} ,
6061
{%- endif %}
6162
{%- endfor %}
6263

6364
{%- for variable_symbol in neuron.get_continuous_input_ports() %}
6465
{%- if variable_symbol.get_initial_value() == None %}
65-
{{variable_symbol.get_symbol_name()}} = 0.0,
66+
{{variable_symbol.get_symbol_name()}} = 0.0,
6667
{%- else %}
6768
{{variable_symbol.get_symbol_name()}} = {{variable_symbol.get_initial_value()}} ,
6869
{%- endif %}

Diff for: pynestml/codegeneration/resources_spinnaker/@NEURON_NAME@_impl.py.jinja2

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# You should have received a copy of the GNU General Public License
1919
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
2020
#
21-
# Generated from NESTML at time: {{now}}
21+
# Generated from NESTML {{ nestml_version }} at time: {{ now }}
2222

2323
from spinn_front_end_common.interface.ds import DataType
2424
from spinn_front_end_common.utilities.constants import BYTES_PER_WORD
@@ -147,7 +147,7 @@ class {{neuronName}}Impl(AbstractNeuronImpl):
147147
return [
148148
{%- for sym in neuron.get_state_symbols() | sort(attribute="name")%}
149149
"{{sym.get_symbol_name()}}",
150-
{%- endfor %}
150+
{%- endfor %}
151151
]
152152

153153
@overrides(AbstractNeuronImpl.get_recordable_data_types)

0 commit comments

Comments
 (0)