Hi,
I'd like to find the distance of a node from the origin without using the currently accessed section functionality. Is there a way to do this in Python?
Mike
getting distance without using currently accessed section
Moderator: hines
-
- Site Admin
- Posts: 6289
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: getting distance without using currently accessed section
Sounds like a contradiction in terms to me, whether in Python or any other language. The section to which a node belongs is part of what distinguishes it from any other node in a model cell. But maybe somebody else will have an answer, in which case I'll learn something new (for the nth time today . . . )vellamike wrote:I'd like to find the distance of a node from the origin without using the currently accessed section functionality. Is there a way to do this in Python?
Re: getting distance without using currently accessed section
To use the "distance" function you need to specify the section, either implicitly as in a
for sec in h.allsec():
for seg in sec:
print h.distance(seg.x)
or explicitly as in
print h.distance(dend(.5).x, sec=dend)
However, this is certainly one of those functions that cries out for greater pythonicity as in
print h.distance(dend(.5))
which presents all the informatin needed to compute the distance (from the origin).
This is one of a number of such cases, many of which have already been modified to have a pythonic variant (i.e. take a segment arg instead
of a section, x pair.) I need to look into the possibility of doing this generically.
for sec in h.allsec():
for seg in sec:
print h.distance(seg.x)
or explicitly as in
print h.distance(dend(.5).x, sec=dend)
However, this is certainly one of those functions that cries out for greater pythonicity as in
print h.distance(dend(.5))
which presents all the informatin needed to compute the distance (from the origin).
This is one of a number of such cases, many of which have already been modified to have a pythonic variant (i.e. take a segment arg instead
of a section, x pair.) I need to look into the possibility of doing this generically.