Hi,
I was having the same problem and thought I should chime in with some details.
I am referring to the documentation found here:
http://www.neuron.yale.edu/neuron/stati ... fit_praxis
I executed the following in Mac OSX 10.6.
With NEURON 7.1, I run the following code, which is the hoc example given for fit_praxis:
Code: Select all
objref vec
vec = new Vector(2) // vec.x[0] is x, vec.x[1] is y
func efun() {local x, y
x = $&2[0] y = $&2[1]
return (x+y - 5)^2 + 5*(x-y - 15)^2
}
attr_praxis(1e-5, .5, 0)
e = fit_praxis(vec.size(), "efun", vec)
printf("e=%g x=%g y=%g\n", e, vec.x[0], vec.x[1])
objref paxis
paxis = new Vector()
for i=0, 1 {
pval = pval_praxis(i, paxis)
printf("%d %10g %10g %10g\n", i, pval, paxis.x[0], paxis.x[1])
}
The output:
Code: Select all
0
bad stack access: expecting (double *); really (Object **)
nrniv: interpreter stack type error
in test.hoc near line 8
e = fit_praxis(vec.size(), "efun", vec)
^
fit_praxis(2, "efun", Vector[0])
I run the same hoc code in NEURON 7.2 alpha downloaded from here:
http://www.neuron.yale.edu/ftp/neuron/versions/alpha/
The output:
Code: Select all
0
e=0 x=10 y=-5
14
0 10 0.707107 -0.707107
1 2.02959 -0.748803 -0.662792
I also tried executing the following python version (saved as test.py):
Code: Select all
from neuron import h
v = h.Vector(2)
def efun(v):
return (v.x[0]+v.x[1] - 5)**2 + 5*(v.x[0]-v.x[1] - 15)**2
h.attr_praxis(1e-5, .5, 0)
e = h.fit_praxis(efun, v)
print "e=%g x=%g y=%g\n"%(e, v.x[0], v.y[0])
Output with NEURON 7.1: nrniv -python test.py
Code: Select all
bad stack access: expecting (double); really (Object *)
nrniv: interpreter stack type error
near line 0
objref hoc_obj_[2]
^
fit_praxis(..., ...)
Traceback (most recent call last):
File "test.py", line 6, in <module>
e = h.fit_praxis(efun, v)
RuntimeError: hoc error
>>>
Output with NEURON 7.2 alpha:
Code: Select all
bad stack access: expecting (double); really (Object *)
/Applications/NEURON-7.2/nrn/umac/bin/nrniv: interpreter stack type error
near line 0
objref hoc_obj_[2]
^
fit_praxis(..., ...)
Traceback (most recent call last):
File "test.py", line 6, in <module>
e = h.fit_praxis(efun, v)
RuntimeError: hoc error
>>>
Typo. Should v.y[0] in the python example read v.x[1]?
Many thanks,
Ashutosh