[SciPy-user] scipy.odr crashes when raising odr_stop
Daniel
daelfin at gmail.com
Thu Nov 13 20:22:46 EST 2008
I'm using scipy.odr and trying to constrain my parameter
values to a certain range, by raising stop_odr from my
fitting function -- however raising stop_odr causes a
crash.
This happens both on a mac (Leopard, Python 2.5.2, Numpy 1.2.1,
Scipy 0.7.0.dev4576) and on Windows (Vista32, Python 2.5.2,
Numpy 1.2, Scipy 0.6.0).
A simplified version along with its output is below.
Any suggestions on how to fix, or workarounds?
Thanks!
--Daniel
---test.py-----------------------------------------------
import sys
from numpy import arange, abs
from scipy.odr import odr_stop, Model, RealData, ODR
def f(B, x):
print >>sys.stderr, "f called, B=", B
if B[1] < 0:
raise odr_stop
return B[0]*x + B[1]
x = arange(10.)
y = .1*x**2+1
m = Model(f)
d = RealData(x, y)
o = ODR(d, m, [.5, 1])
out = o.run()
out.pprint()
---------------------------------------------------------
$ python test.py
f called, B= [ 0.5 1. ]
...a few more times...
f called, B= [ 0.9 -0.20000001]
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/warnings.py:80:
RuntimeWarning: tp_compare didn't return -1 or -2 for exception
if registry.get(key):
Bus error
More information about the SciPy-User
mailing list