Skip to content

Commit

Permalink
feat(neuron/netpyne): use %r instead of %e or %s
Browse files Browse the repository at this point in the history
when writing recorded data to file.

`%r` or the `repr` function gives the "official" string representation
of an object, so of a float too, while the `%s` or `str` method returns
the "nicely printable string representation of an object".

Also, irrespective of which one we use, we must use the same for both
NEURON and NetPyNE.
  • Loading branch information
sanjayankur31 committed Jan 26, 2024
1 parent 6e409b5 commit 9511625
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/neuroml/export/neuron/NeuronWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ else if(cc.getComponentType().isOrExtends(NeuroMLElements.CONTINUOUS_CONNECTION_
}

//columnsPostTraces.get(outfileId).add(bIndent+" f_" + outfileId + "_f2.write('%e\\t'% py_v_" + timeRef + "[i] ");
columnsPostTraces.get(outfileId).add(bIndent+" f_" + outfileId + "_f2.write('%e\\t");
columnsPostTraces.get(outfileId).add(bIndent+" f_" + outfileId + "_f2.write('%r\\t");
writingVariables.get(outfileId).add("py_v_" + timeRef + "[i], ");

ArrayList<String> colIds = new ArrayList<String>();
Expand Down Expand Up @@ -1476,7 +1476,7 @@ else if(cc.getComponentType().isOrExtends(NeuroMLElements.CONTINUOUS_CONNECTION_
/*columnsPostTraces.get(outfileId).add(
" + '%e\\t'%(py_v_" + colId + "[i]) ");*/

columnsPostTraces.get(outfileId).add("%e\\t");
columnsPostTraces.get(outfileId).add("%r\\t");
writingVariables.get(outfileId).add("py_v_" + colId + "[i], ");

}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/netpyne/run.vm
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class NetPyNESimulation():

dat_file_$of.name = open('$of.file_name', 'w')
for i in range(len(col_${of.name}_t)):
dat_file_${of.name}.write(#foreach ($oc in $of.output_columns ) '%s\t'%(col_${of.name}_${oc.name}[i]/${oc.neuron_variable_scale}) + #end '\n')
dat_file_${of.name}.write(#foreach ($oc in $of.output_columns ) '%r\t'%(col_${of.name}_${oc.name}[i]/${oc.neuron_variable_scale}) + #end '\n')
dat_file_${of.name}.close()

#end
Expand All @@ -201,10 +201,10 @@ class NetPyNESimulation():
if id in to_record_keys:
#if ($of.spike_file_format=="ID_TIME")

spike_file_${of.name}.write('%i\t%s\n'%(to_record[id],t/1000.)) # format: $of.spike_file_format
spike_file_${of.name}.write('%i\t%r\n'%(to_record[id],t/1000.)) # format: $of.spike_file_format
#else

spike_file_${of.name}.write('%s\t%i\n'%(t/1000.,to_record[id])) # format: $of.spike_file_format
spike_file_${of.name}.write('%r\t%i\n'%(t/1000.,to_record[id])) # format: $of.spike_file_format
#end

spike_file_${of.name}.close()
Expand Down

0 comments on commit 9511625

Please sign in to comment.