Skip to content

Commit 97ba231

Browse files
authored
Merge pull request #770 from apdavison/fix-describe
fix some issues with the `describe()` method - see #768 and #769
2 parents ff898b5 + 0d65d20 commit 97ba231

File tree

9 files changed

+16
-34
lines changed

9 files changed

+16
-34
lines changed

pyNN/descriptions/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
:license: CeCILL, see LICENSE for details.
2323
"""
2424

25+
from collections.abc import Mapping
2526
import string
2627
import os.path
2728

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

113119

pyNN/descriptions/templates/cheetah/population_old.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Structure '$name' with the following parameters:
2+
#for $key,$value in $parameters.items()
3+
$key: $value
4+
#end for

pyNN/descriptions/templates/jinja2/population_old.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.

pyNN/descriptions/templates/jinja2/populationview_default.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ PopulationView "{{label}}"
22
parent : "{{parent}}"
33
size : {{size}}
44
mask : {{mask}}
5-

pyNN/descriptions/templates/jinja2/projection_default.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ Projection "{{label}}" from "{{pre.label}}" ({{pre.size}} cells) to "{{post.labe
1818
Dendritic delay fraction : {{plasticity.slow.dendritic_delay_fraction}}{% endif %}{% else %}None{% endif %}
1919
Total connections : {{size}}
2020
Local connections : {{size_local}}
21-
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Structure '{{name}}' with the following parameters:
2+
{%- for key,value in parameters.items() %}
3+
{{key}} : {{value}}{% endfor %}

pyNN/descriptions/templates/string/population_default.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Population "$label"
2-
Structure : $structure
2+
Structure : $structure_name
33
Local cells : $size_local
4-
Cell type : $celltype.name
4+
Cell type : $celltype_name
55
ID range : $first_id-$last_id
66
First cell on this node:
77
ID: $local_first_id
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Structure '$name' with the following parameters: $parameters

0 commit comments

Comments
 (0)