Skip to content

Commit c6497f0

Browse files
authored
Merge pull request #52 from ModECI/test_xml3
Valid NeuroML generation
2 parents 322953f + 6339fd0 commit c6497f0

20 files changed

+423
-88
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ jobs:
5555
cd test
5656
python test.py
5757
58+
## Test NeuroML example
59+
60+
cd ../neuroml2
61+
python neuroml2_spec.py
62+
63+
pip install pyneuroml
64+
65+
# Requires: pip install pyneuroml
66+
pynml -validate hello_world_neuroml.net.nml
67+
pynml -validate TestNeuroML.xml
68+
5869
- name: Run pytest
5970
run: |
6071
pytest tests

docs/sphinx/source/api/examples/document.py

Lines changed: 8 additions & 2 deletions
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+
import sys
56

67
# Example showing how to create a model of a document and use it to create/serialize instances
78

@@ -69,11 +70,16 @@ class Document(Base):
6970

7071
doc.to_json_file("document.json")
7172
doc.to_yaml_file("document.yaml")
73+
print(" >> Full document details in YAML format:\n")
74+
print(doc.to_yaml())
75+
7276
doc.to_bson_file("document.bson")
7377

74-
print(" >> Full document details in YAML format:\n")
78+
if sys.version_info >= (3, 8):
79+
doc.to_xml_file("document.xml")
80+
print(" >> Full document details in XML format:\n")
81+
print(doc.to_xml())
7582

76-
print(doc.to_yaml())
7783

7884
doc_md = doc.generate_documentation(format="markdown")
7985

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
<Document id="MyBook" title="My life in Python" ISBN="None">
3+
<Section id="Abstract">
4+
<Paragraph contents="Blah blah blah"/>
5+
<Paragraph contents="Blah2"/>
6+
</Section>
7+
<Section id="Chapter 1">
8+
<Paragraph contents="More..."/>
9+
</Section>
10+
</Document>

examples/document.py

Lines changed: 8 additions & 2 deletions
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+
import sys
56

67
# Example showing how to create a model of a document and use it to create/serialize instances
78

@@ -69,11 +70,16 @@ class Document(Base):
6970

7071
doc.to_json_file("document.json")
7172
doc.to_yaml_file("document.yaml")
73+
print(" >> Full document details in YAML format:\n")
74+
print(doc.to_yaml())
75+
7276
doc.to_bson_file("document.bson")
7377

74-
print(" >> Full document details in YAML format:\n")
78+
if sys.version_info >= (3, 8):
79+
doc.to_xml_file("document.xml")
80+
print(" >> Full document details in XML format:\n")
81+
print(doc.to_xml())
7582

76-
print(doc.to_yaml())
7783

7884
doc_md = doc.generate_documentation(format="markdown")
7985

examples/document.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
<Document id="MyBook" title="My life in Python" ISBN="None">
3+
<Section id="Abstract">
4+
<Paragraph contents="Blah blah blah"/>
5+
<Paragraph contents="Blah2"/>
6+
</Section>
7+
<Section id="Chapter 1">
8+
<Paragraph contents="More..."/>
9+
</Section>
10+
</Document>

examples/neuroml2/NeuroML2.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## NeuroML
1+
## neuroml
22
Some description...
33

44
### Allowed parameters
@@ -11,9 +11,9 @@ Some description...
1111

1212

1313
<tr>
14-
<td><b>version</b></td>
14+
<td><b>xmlns</b></td>
1515
<td>str</td>
16-
<td><i>NeuroML version used</i></td>
16+
<td><i>Schema for NeuroML 2, usually http://www.neuroml.org/schema/neuroml2</i></td>
1717
</tr>
1818

1919

@@ -23,28 +23,28 @@ Some description...
2323
<table>
2424
<tr>
2525
<td><b>izhikevich2007Cells</b></td>
26-
<td><a href="#izhikevich2007cell">Izhikevich2007Cell</a></td>
26+
<td><a href="#izhikevich2007cell">izhikevich2007Cell</a></td>
2727
<td><i></i></td>
2828
</tr>
2929

3030

3131
<tr>
3232
<td><b>pulseGenerators</b></td>
33-
<td><a href="#pulsegenerator">PulseGenerator</a></td>
33+
<td><a href="#pulsegenerator">pulseGenerator</a></td>
3434
<td><i></i></td>
3535
</tr>
3636

3737

3838
<tr>
3939
<td><b>networks</b></td>
40-
<td><a href="#network">Network</a></td>
40+
<td><a href="#network">network</a></td>
4141
<td><i>The networks present</i></td>
4242
</tr>
4343

4444

4545
</table>
4646

47-
## Izhikevich2007Cell
47+
## izhikevich2007Cell
4848
Some description...
4949

5050
### Allowed parameters
@@ -128,7 +128,7 @@ Some description...
128128

129129
</table>
130130

131-
## PulseGenerator
131+
## pulseGenerator
132132
Some description...
133133

134134
### Allowed parameters
@@ -163,7 +163,7 @@ Some description...
163163

164164
</table>
165165

166-
## Network
166+
## network
167167
Some description...
168168

169169
### Allowed parameters
@@ -181,21 +181,21 @@ Some description...
181181
<table>
182182
<tr>
183183
<td><b>populations</b></td>
184-
<td><a href="#population">Population</a></td>
184+
<td><a href="#population">population</a></td>
185185
<td><i>the pops in the net</i></td>
186186
</tr>
187187

188188

189189
<tr>
190190
<td><b>explicitInputs</b></td>
191-
<td><a href="#explicitinput">ExplicitInput</a></td>
191+
<td><a href="#explicitinput">explicitInput</a></td>
192192
<td><i></i></td>
193193
</tr>
194194

195195

196196
</table>
197197

198-
## Population
198+
## population
199199
Some description...
200200

201201
### Allowed parameters
@@ -223,7 +223,7 @@ Some description...
223223

224224
</table>
225225

226-
## ExplicitInput
226+
## explicitInput
227227
Some description...
228228

229229
### Allowed parameters

examples/neuroml2/NeuroML2.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
=======
2-
NeuroML
2+
neuroml
33
=======
44
Some description...
55

66
**Allowed parameters**
77

8-
=============== =========== ================================
8+
=============== =========== ====================================================================
99
Allowed field Data Type Description
10-
=============== =========== ================================
10+
=============== =========== ====================================================================
1111
**id** str The id of the NeuroML 2 document
12-
**version** str NeuroML version used
13-
=============== =========== ================================
12+
**xmlns** str Schema for NeuroML 2, usually http://www.neuroml.org/schema/neuroml2
13+
=============== =========== ====================================================================
1414

1515
**Allowed children**
1616

1717
======================= ============================================ ====================
1818
Allowed child Data Type Description
1919
======================= ============================================ ====================
20-
**izhikevich2007Cells** `Izhikevich2007Cell <#izhikevich2007cell>`__
21-
**pulseGenerators** `PulseGenerator <#pulsegenerator>`__
22-
**networks** `Network <#network>`__ The networks present
20+
**izhikevich2007Cells** `izhikevich2007Cell <#izhikevich2007cell>`__
21+
**pulseGenerators** `pulseGenerator <#pulsegenerator>`__
22+
**networks** `network <#network>`__ The networks present
2323
======================= ============================================ ====================
2424

2525
==================
26-
Izhikevich2007Cell
26+
izhikevich2007Cell
2727
==================
2828
Some description...
2929

@@ -46,7 +46,7 @@ Allowed field Data Type Description
4646
=============== =========== =====================
4747

4848
==============
49-
PulseGenerator
49+
pulseGenerator
5050
==============
5151
Some description...
5252

@@ -62,7 +62,7 @@ Allowed field Data Type Description
6262
=============== =========== ============================
6363

6464
=======
65-
Network
65+
network
6666
=======
6767
Some description...
6868

@@ -79,12 +79,12 @@ Allowed field Data Type Description
7979
================== ================================== ===================
8080
Allowed child Data Type Description
8181
================== ================================== ===================
82-
**populations** `Population <#population>`__ the pops in the net
83-
**explicitInputs** `ExplicitInput <#explicitinput>`__
82+
**populations** `population <#population>`__ the pops in the net
83+
**explicitInputs** `explicitInput <#explicitinput>`__
8484
================== ================================== ===================
8585

8686
==========
87-
Population
87+
population
8888
==========
8989
Some description...
9090

@@ -99,7 +99,7 @@ Allowed field Data Type Description
9999
=============== =========== ======================================
100100

101101
=============
102-
ExplicitInput
102+
explicitInput
103103
=============
104104
Some description...
105105

examples/neuroml2/NeuroML2.specification.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"NeuroML": {
2+
"neuroml": {
33
"definition": "Some description...",
44
"allowed_parameters": {
55
"id": {
66
"type": "str",
77
"description": "The id of the NeuroML 2 document"
88
},
9-
"version": {
9+
"xmlns": {
1010
"type": "str",
11-
"description": "NeuroML version used"
11+
"description": "Schema for NeuroML 2, usually http://www.neuroml.org/schema/neuroml2"
1212
}
1313
},
1414
"allowed_children": {
1515
"izhikevich2007Cells": {
16-
"type": "Izhikevich2007Cell",
16+
"type": "izhikevich2007Cell",
1717
"description": ""
1818
},
1919
"pulseGenerators": {
20-
"type": "PulseGenerator",
20+
"type": "pulseGenerator",
2121
"description": ""
2222
},
2323
"networks": {
24-
"type": "Network",
24+
"type": "network",
2525
"description": "The networks present"
2626
}
2727
}
2828
},
29-
"Izhikevich2007Cell": {
29+
"izhikevich2007Cell": {
3030
"definition": "Some description...",
3131
"allowed_parameters": {
3232
"id": {
@@ -75,7 +75,7 @@
7575
}
7676
}
7777
},
78-
"PulseGenerator": {
78+
"pulseGenerator": {
7979
"definition": "Some description...",
8080
"allowed_parameters": {
8181
"id": {
@@ -96,7 +96,7 @@
9696
}
9797
}
9898
},
99-
"Network": {
99+
"network": {
100100
"definition": "Some description...",
101101
"allowed_parameters": {
102102
"id": {
@@ -106,16 +106,16 @@
106106
},
107107
"allowed_children": {
108108
"populations": {
109-
"type": "Population",
109+
"type": "population",
110110
"description": "the pops in the net"
111111
},
112112
"explicitInputs": {
113-
"type": "ExplicitInput",
113+
"type": "explicitInput",
114114
"description": ""
115115
}
116116
}
117117
},
118-
"Population": {
118+
"population": {
119119
"definition": "Some description...",
120120
"allowed_parameters": {
121121
"id": {
@@ -132,7 +132,7 @@
132132
}
133133
}
134134
},
135-
"ExplicitInput": {
135+
"explicitInput": {
136136
"definition": "Some description...",
137137
"allowed_parameters": {
138138
"target": {

0 commit comments

Comments
 (0)