Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeVarPlot enhancements #706

Merged
merged 4 commits into from
Aug 19, 2020
Merged

RangeVarPlot enhancements #706

merged 4 commits into from
Aug 19, 2020

Conversation

ramcdougal
Copy link
Member

Support for rxd, e.g.

rvp = h.RangeVarPlot(ca, dend(0), dend(1))

or

rvp = h.RangeVarPlot(ca[er], dend(0), dend(1))

and a new method that returns a new Vector (the old rvp.to_vector only manipulates an existing Vector):

vec = rvp.vector()

@ramcdougal ramcdougal added the wip label Aug 14, 2020
@ramcdougal ramcdougal changed the title RangeVarPlot enhancements RangeVarPlot enhancements -- wip do not merge Aug 14, 2020
@ramcdougal
Copy link
Member Author

This is a work in progress because of the following bug:

If you run this:

from neuron import h, rxd

dend = h.Section(name='dend')
dend.nseg = 3

cyt = rxd.Region([dend], name='cyt')
c = rxd.Species(cyt)#, initial=lambda node: 1 if 0.4 < node.x < 0.6 else 0)

rvp = h.RangeVarPlot('v', dend(0), dend(1))

h.finitialize(-65)
print(list(rvp.vector()))

you'll see the 5 values (3 segments + endpoints):

[-65.0, -65.0, -65.0, -65.0, -65.0]

which is correct. If instead, you uncomment the species initialization:

c = rxd.Species(cyt, initial=lambda node: 1 if 0.4 < node.x < 0.6 else 0)

it incorrectly shows 10 values (and with a slight modification, one can show that it generates two copies of the correct values):

[-65.0, -65.0, -65.0, -65.0, -65.0, -65.0, -65.0, -65.0, -65.0, -65.0]

If the RangeVarPlot is defined after the finitialize, it works correctly.

This is mysterious because neuron-nightly doesn't do this, the RangeVarPlot doesn't involve rxd, and the new code is essentially unused in this case. Any thoughts @pramodk , @adamjhn , @nrnhines ?

@ramcdougal
Copy link
Member Author

ramcdougal commented Aug 15, 2020

Ok, so the above bug does NOT appear to be a bug in this commit, as it appears when I build NEURON from sources (d1ba505) using autotools (or cmake) on Ubuntu 20.04 (with Python 3.8.2) but it does not occur if I use the pip install neuron-nightly (dbeb52b) on Google Colab or on Ubuntu 20.04.

The test needs to be slightly revised to run on those versions as they do not have a .vector method:

from neuron import h, rxd

dend = h.Section(name='dend')
dend.nseg = 3

cyt = rxd.Region([dend], name='cyt')
c = rxd.Species(cyt)#, initial=lambda node: 1 if 0.4 < node.x < 0.6 else 0)

rvp = h.RangeVarPlot('v', dend(0), dend(1))

h.finitialize(-65)
y = h.Vector()
rvp.to_vector(y)
print(list(y))

@ramcdougal ramcdougal removed the wip label Aug 15, 2020
@ramcdougal ramcdougal changed the title RangeVarPlot enhancements -- wip do not merge RangeVarPlot enhancements Aug 15, 2020
@ramcdougal
Copy link
Member Author

I removed the WIP designation since the bug doesn't seem to be coming from here.

@ramcdougal ramcdougal requested a review from adamjhn August 19, 2020 22:01
Copy link
Member

@nrnhines nrnhines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Have you tested to your satisfaction?

@ramcdougal
Copy link
Member Author

Yes. I think this is ready to merge.

@nrnhines nrnhines merged commit 19cb091 into master Aug 19, 2020
@nrnhines nrnhines deleted the rvp-enhancements branch August 19, 2020 23:58
def _nrnpy_rvp_pyobj_callback(f):
# unless f is an rxd variable, we return it directly
f_type = str(type(f))
if f_type not in ("<class 'neuron.rxd.species.SpeciesOnRegion'>", "<class 'neuron.rxd.species.Species'>"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include "<class 'neuron.rxd.species.State'>", "<class 'neuron.rxd.species.Parameter'>" and "<class 'neuron.rxd.species.ParameterOnRegion'>"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plotshape and rangevarplot should work with rxd objects
3 participants