neuronsimulator / nrn

NEURON Simulator
http://nrn.readthedocs.io
Other
404 stars 118 forks source link

cvode.statename does not necessarily return HOC names for sections #1076

Open ramcdougal opened 3 years ago

ramcdougal commented 3 years ago

Consider the following code:

sec = h.Section(name="sec")
sec.nseg = 5

h.CVode().active(True)
s = h.ref('')
for i in range(5):
    h.CVode().statename(i, s, 0)
    print(s[0])

Per the docs, this "Return the HOC name of the i’th string".

However, it prints out sec.v(0.1), etc... which is not a name that HOC is aware of. (It does know about sec.hoc_internal_name()) Most of the time, I think this behavior is reasonable, however it would be nice to have a style option that returns something that can be used to grab the corresponding section.

nrnhines commented 3 years ago

HOC is aware of _pysec.sec. The problem is name consistency. It may be as simple as replacing every (relevant?) internal secname(sec) call with nrn_sec2pysecname(sec)

ramcdougal commented 3 years ago

I suspect most of the time I don't want to see the _pysec, so I'm not sure that including it should be the default...

nrnhines commented 3 years ago

Yes. It is only required for syntactic sugar in the hoc world (generally so hoc gui tools have a name for python sections.) Those names are slightly superior to the internal names that refer to pointer locations as they persist across launches.