Numpy array to hoc vector
Posted: Wed Jun 12, 2013 4:15 pm
I'm able to convert a hoc vector to a numpy array using:
But I am unable to convert a numpy array back to hoc. The following code gives me the error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'vec' is not defined
0
I also tried using the methods presented by Hines et al. on page 7 of NEURON and Python:
which yielded the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Vector'
0
Any thoughts on this? I'm running Neuron version 7.3 with python embedded as an alternative interpreter to hoc.
Code: Select all
nrnpython("import neuron")
nrnpython("from neuron import h")
nrnpython("xref = array('d',h.refSTNv)")
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'vec' is not defined
0
Code: Select all
nrnpython("a = [1,2]")
objref vec
vec = new Vector()
nrnpython("vec - vec.from_python(a)")
Code: Select all
nrnpython("vec = h.Vector(a)")
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Vector'
0
Any thoughts on this? I'm running Neuron version 7.3 with python embedded as an alternative interpreter to hoc.