Skip to content

Commit

Permalink
add NESTML version to generated code (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
clinssen authored Feb 12, 2025
1 parent b786d5f commit cf274da
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 21 deletions.
5 changes: 4 additions & 1 deletion pynestml/codegeneration/nest_code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,13 @@ def _get_module_namespace(self, neurons: List[ASTModel], synapses: List[ASTModel
namespace = {"neurons": neurons,
"synapses": synapses,
"moduleName": FrontendConfiguration.get_module_name(),
"nestml_version": pynestml.__version__,
"now": datetime.datetime.utcnow()}

# NEST version
if self.option_exists("nest_version"):
namespace["nest_version"] = self.get_option("nest_version")

return namespace

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

def _get_model_namespace(self, astnode: ASTModel) -> Dict:

namespace = {}

namespace["nestml_version"] = pynestml.__version__
namespace["now"] = datetime.datetime.utcnow()
namespace["tracing"] = FrontendConfiguration.is_dev

Expand Down
2 changes: 2 additions & 0 deletions pynestml/codegeneration/nest_compartmental_code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def _get_module_namespace(self, neurons: List[ASTModel]) -> Dict:
namespace = {"neurons": neurons,
"nest_version": self.get_option("nest_version"),
"moduleName": FrontendConfiguration.get_module_name(),
"nestml_version": pynestml.__version__,
"now": datetime.datetime.utcnow()}

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

namespace = {}

namespace["nestml_version"] = pynestml.__version__
namespace["now"] = datetime.datetime.utcnow()
namespace["tracing"] = FrontendConfiguration.is_dev

Expand Down
2 changes: 2 additions & 0 deletions pynestml/codegeneration/nest_desktop_code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

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

import pynestml
from pynestml.codegeneration.code_generator import CodeGenerator
from pynestml.codegeneration.code_generator_utils import CodeGeneratorUtils
from pynestml.meta_model.ast_model import ASTModel
Expand Down Expand Up @@ -64,6 +65,7 @@ def _get_neuron_model_namespace(self, neuron: ASTModel) -> Dict:
from pynestml.codegeneration.nest_tools import NESTTools

namespace = dict()
namespace["nestml_version"] = pynestml.__version__
namespace["neuronName"] = neuron.get_name()
namespace["neuron"] = neuron
namespace["parameters"] = NESTTools.get_neuron_parameters(neuron.get_name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ along with NEST. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* Generated from NESTML at time: {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
**/

// C++ includes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ along with NEST. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* Generated from NESTML at time: {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
**/
#ifndef {{neuronName.upper()}}
#define {{neuronName.upper()}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ along with NEST. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* Generated from NESTML at time: {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
**/

#ifndef {{synapseName.upper()}}_H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
*/

// Includes from nestkernel:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
*/

// Include from NEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
*/

#ifndef {{upperModuleName}}_H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
*/

// Includes from nestkernel:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
*/

// Include from NEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
* {{now}}
* Generated from NESTML {{ nestml_version }} at time: {{ now }}
*/

#ifndef {{upperModuleName}}_H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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 <http://www.gnu.org/licenses/>.

Generated from NESTML at time: {{now}}
Generated from NESTML {{ nestml_version }} at time: {{ now }}
"""

{% if tracing %}# generated by {{self._TemplateReference__context.name}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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 <http://www.gnu.org/licenses/>.

Generated from NESTML at time: {{now}}
Generated from NESTML {{ nestml_version }} at time: {{ now }}
"""

{% if tracing %}# generated by {{self._TemplateReference__context.name}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 <http://www.gnu.org/licenses/>.

Generated from NESTML at time: {{now}}
Generated from NESTML {{ nestml_version }} at time: {{ now }}
"""

from typing import List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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 <http://www.gnu.org/licenses/>.

Generated from NESTML at time: {{now}}
Generated from NESTML {{ nestml_version }} at time: {{ now }}
"""

from typing import List, Mapping, Optional, Union
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 <http://www.gnu.org/licenses/>.

Generated from NESTML at time: {{now}}
Generated from NESTML {{ nestml_version }} at time: {{ now }}
"""

from .neuron import Neuron
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 <http://www.gnu.org/licenses/>.

Generated from NESTML at time: {{now}}
Generated from NESTML {{ nestml_version }} at time: {{ now }}
"""

from typing import List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
#
# Generated from NESTML at time: {{now}}
# Generated from NESTML {{ nestml_version }} at time: {{ now }}

from numpy import exp, ceil

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

{%- for variable_symbol in neuron.get_spike_input_ports() %}
{%- if variable_symbol.get_initial_value() == None %}
{{variable_symbol.get_symbol_name()}} = 0.0,
{{variable_symbol.get_symbol_name()}} = 0.0,
{%- else %}
{{variable_symbol.get_symbol_name()}} = {{variable_symbol.get_initial_value()}} ,
{%- endif %}
{%- endfor %}

{%- for variable_symbol in neuron.get_continuous_input_ports() %}
{%- if variable_symbol.get_initial_value() == None %}
{{variable_symbol.get_symbol_name()}} = 0.0,
{{variable_symbol.get_symbol_name()}} = 0.0,
{%- else %}
{{variable_symbol.get_symbol_name()}} = {{variable_symbol.get_initial_value()}} ,
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
#
# Generated from NESTML at time: {{now}}
# Generated from NESTML {{ nestml_version }} at time: {{ now }}

from spinn_front_end_common.interface.ds import DataType
from spinn_front_end_common.utilities.constants import BYTES_PER_WORD
Expand Down Expand Up @@ -147,7 +147,7 @@ class {{neuronName}}Impl(AbstractNeuronImpl):
return [
{%- for sym in neuron.get_state_symbols() | sort(attribute="name")%}
"{{sym.get_symbol_name()}}",
{%- endfor %}
{%- endfor %}
]

@overrides(AbstractNeuronImpl.get_recordable_data_types)
Expand Down

0 comments on commit cf274da

Please sign in to comment.