Skip to content

Commit cfb2f98

Browse files
authored
Merge pull request #248 from kedoxey/dev
Added function to return state variables
2 parents b0e681f + 62501db commit cfb2f98

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

neuronunit/models/lems.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,21 @@ def has_pulse_generator(self, tree=None):
206206
def temp_dir(self):
207207
if not hasattr(self, '_temp_dir'):
208208
self._temp_dir = TemporaryDirectory()
209-
return self._temp_dir
209+
return self._temp_dir
210+
211+
def get_state_variables(self):
212+
"""
213+
Parses LEMS xml file and gets simulation's state variables from
214+
OutputFile element.
215+
216+
Returns:
217+
Dict of type "string: string" with the format "id: quantity"
218+
219+
"""
220+
lems_tree = etree.parse(self.lems_file_path)
221+
state_variables = {'t': 't'}
222+
for output_column in lems_tree.iter('OutputColumn'):
223+
id = output_column.attrib['id']
224+
quantity = output_column.attrib['quantity']
225+
state_variables[id] = quantity
226+
return state_variables

0 commit comments

Comments
 (0)