Skip to content

Commit 9f8c144

Browse files
accompanying files from merge with upstream development branch
1 parent 976597c commit 9f8c144

File tree

8 files changed

+94
-20
lines changed

8 files changed

+94
-20
lines changed

examples/neuroml2/NeuroML2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Some description...
2323
<table>
2424
<tr>
2525
<td><b>networks</b></td>
26-
<td><a href="#network">Network</a></td>
26+
<td><a href="#list">List</a></td>
2727
<td><i>The networks present</i></td>
2828
</tr>
2929

@@ -48,7 +48,7 @@ Some description...
4848
<table>
4949
<tr>
5050
<td><b>populations</b></td>
51-
<td><a href="#population">Population</a></td>
51+
<td><a href="#list">List</a></td>
5252
<td><i>the pops in the net</i></td>
5353
</tr>
5454

examples/neuroml2/NeuroML2.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Allowed field Data Type Description
1414

1515
**Allowed children**
1616

17-
=============== ====================== ====================
18-
Allowed child Data Type Description
19-
=============== ====================== ====================
20-
**networks** `Network <#network>`__ The networks present
21-
=============== ====================== ====================
17+
=============== ================ ====================
18+
Allowed child Data Type Description
19+
=============== ================ ====================
20+
**networks** `List <#list>`__ The networks present
21+
=============== ================ ====================
2222

2323
=======
2424
Network
@@ -35,11 +35,11 @@ Allowed field Data Type Description
3535

3636
**Allowed children**
3737

38-
=============== ============================ ===================
39-
Allowed child Data Type Description
40-
=============== ============================ ===================
41-
**populations** `Population <#population>`__ the pops in the net
42-
=============== ============================ ===================
38+
=============== ================ ===================
39+
Allowed child Data Type Description
40+
=============== ================ ===================
41+
**populations** `List <#list>`__ the pops in the net
42+
=============== ================ ===================
4343

4444
==========
4545
Population

examples/neuroml2/NeuroML2.specification.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"allowed_children": {
1515
"networks": {
16-
"type": "Network",
16+
"type": "List",
1717
"description": "The networks present"
1818
}
1919
}
@@ -28,7 +28,7 @@
2828
},
2929
"allowed_children": {
3030
"populations": {
31-
"type": "Population",
31+
"type": "List",
3232
"description": "the pops in the net"
3333
}
3434
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" ?>
2+
<root>
3+
<NeuroML>
4+
<definition>Some description...</definition>
5+
<allowed_parameters>
6+
<id>
7+
<type>str</type>
8+
<description>The id of the NeuroML 2 document</description>
9+
</id>
10+
<version>
11+
<type>str</type>
12+
<description>NeuroML version used</description>
13+
</version>
14+
</allowed_parameters>
15+
<allowed_children>
16+
<networks>
17+
<type>List</type>
18+
<description>The networks present</description>
19+
</networks>
20+
</allowed_children>
21+
</NeuroML>
22+
<Network>
23+
<definition>Some description...</definition>
24+
<allowed_parameters>
25+
<id>
26+
<type>str</type>
27+
<description>The id of the network</description>
28+
</id>
29+
</allowed_parameters>
30+
<allowed_children>
31+
<populations>
32+
<type>List</type>
33+
<description>the pops in the net</description>
34+
</populations>
35+
</allowed_children>
36+
</Network>
37+
<Population>
38+
<definition>Some description...</definition>
39+
<allowed_parameters>
40+
<id>
41+
<type>str</type>
42+
<description>The id of the population</description>
43+
</id>
44+
<component>
45+
<type>str</type>
46+
<description>the component to use in the population</description>
47+
</component>
48+
<size>
49+
<type>int</type>
50+
<description>the size of the population</description>
51+
</size>
52+
</allowed_parameters>
53+
</Population>
54+
</root>

examples/neuroml2/NeuroML2.specification.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ NeuroML:
99
description: NeuroML version used
1010
allowed_children:
1111
networks:
12-
type: Network
12+
type: List
1313
description: The networks present
1414
Network:
1515
definition: Some description...
@@ -19,7 +19,7 @@ Network:
1919
description: The id of the network
2020
allowed_children:
2121
populations:
22-
type: Population
22+
type: List
2323
description: the pops in the net
2424
Population:
2525
definition: Some description...

examples/neuroml2/TestNeuroML.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" ?>
2+
<modelspec>
3+
<TestNeuroML>
4+
<version>NeuroML_v2.3</version>
5+
<networks>
6+
<net0>
7+
<populations>
8+
<pop0>
9+
<component>izh2007RS0</component>
10+
<size>1</size>
11+
</pop0>
12+
</populations>
13+
</net0>
14+
</networks>
15+
</TestNeuroML>
16+
</modelspec>

examples/neuroml2/neuroml2_spec.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from modelspec import field, instance_of, optional
33
from modelspec.base_types import Base
44
from typing import List
5+
from modelspec.utils import save_to_xml_file
56

67
# Example showing ...
78

@@ -68,11 +69,12 @@ class NeuroML(Base):
6869
nml_doc.to_json_file("%s.json" % nml_doc.id)
6970
nml_doc.to_yaml_file("%s.yaml" % nml_doc.id)
7071
nml_doc.to_bson_file("%s.bson" % nml_doc.id)
71-
# nml_doc.to_xml_file("%s.xml"%nml_doc.id)
72+
nml_doc.to_xml_file("%s.xml" % nml_doc.id)
7273

7374
print(" >> Full document details in YAML format:\n")
7475

7576
print(nml_doc.to_yaml())
77+
print(nml_doc.to_xml())
7678

7779
doc_md = nml_doc.generate_documentation(format="markdown")
7880

@@ -99,3 +101,5 @@ class NeuroML(Base):
99101
yy = yaml.dump(doc_dict, indent=4, sort_keys=False)
100102
print(yy)
101103
d.write(yy)
104+
105+
save_to_xml_file(doc_dict, "NeuroML2.specification.xml")

src/modelspec/base_types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def to_xml(self) -> str:
121121
"""
122122
from modelspec.utils import build_xml_element
123123

124-
root = ET.Element("root")
124+
root = ET.Element("modelspec")
125125
build_xml_element(root, self.to_dict())
126126

127127
xml_string = ET.tostring(
@@ -265,14 +265,14 @@ def to_xml_file(
265265
self,
266266
filename: Optional[str] = None,
267267
include_metadata: bool = True,
268-
root="modelspec",
268+
root_name="modelspec",
269269
) -> str:
270270
from modelspec.utils import build_xml_element
271271

272272
if filename is None:
273273
filename = f"{self.id}.xml"
274274

275-
root = ET.Element(root)
275+
root = ET.Element(root_name)
276276

277277
build_xml_element(root, self.to_dict())
278278

0 commit comments

Comments
 (0)