Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pyNN/descriptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:license: CeCILL, see LICENSE for details.
"""

from collections.abc import Mapping
import string
import os.path

Expand Down Expand Up @@ -108,6 +109,11 @@ def render(cls, template, context):
context should be a dict.
"""
template = cls.get_template(template)
for key, value in context.copy().items():
# expand one level of any dicts contained in the context
if isinstance(value, Mapping):
for subkey, subvalue in value.items():
context[f"{key}_{subkey}"] = subvalue
return template.safe_substitute(context)


Expand Down
16 changes: 0 additions & 16 deletions pyNN/descriptions/templates/cheetah/population_old.txt

This file was deleted.

4 changes: 4 additions & 0 deletions pyNN/descriptions/templates/cheetah/structure_default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Structure '$name' with the following parameters:
#for $key,$value in $parameters.items()
$key: $value
#end for
14 changes: 0 additions & 14 deletions pyNN/descriptions/templates/jinja2/population_old.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ PopulationView "{{label}}"
parent : "{{parent}}"
size : {{size}}
mask : {{mask}}

1 change: 0 additions & 1 deletion pyNN/descriptions/templates/jinja2/projection_default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ Projection "{{label}}" from "{{pre.label}}" ({{pre.size}} cells) to "{{post.labe
Dendritic delay fraction : {{plasticity.slow.dendritic_delay_fraction}}{% endif %}{% else %}None{% endif %}
Total connections : {{size}}
Local connections : {{size_local}}

3 changes: 3 additions & 0 deletions pyNN/descriptions/templates/jinja2/structure_default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Structure '{{name}}' with the following parameters:
{%- for key,value in parameters.items() %}
{{key}} : {{value}}{% endfor %}
4 changes: 2 additions & 2 deletions pyNN/descriptions/templates/string/population_default.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Population "$label"
Structure : $structure
Structure : $structure_name
Local cells : $size_local
Cell type : $celltype.name
Cell type : $celltype_name
ID range : $first_id-$last_id
First cell on this node:
ID: $local_first_id
Expand Down
1 change: 1 addition & 0 deletions pyNN/descriptions/templates/string/structure_default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Structure '$name' with the following parameters: $parameters