From: Raymond H. <rha...@ea...> - 2011-09-14 19:17:33
|
I'm getting odd behavior when I try to use fmin and pylab in the same program. The issue is illustrated in the code snippet below. As written, fmin won't work: the "print xopt" simply returns the contents of x0 as assigned in the line before fmin. If the "from pylab import *" line is commented out, however, then fmin runs as expected. I'm running python 2.7.2 on a MacBook Pro with a recent install & upgrade of scipy and matplotlib via macports. Any suggestions would be appreciated. ------------------------------------- #!/opt/local/bin/python from scipy import * from scipy.optimize import fmin import matplotlib matplotlib.use('MacOSX') from pylab import * def rosen(x): # The Rosenbrock function return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0) x0 = [1.3, 0.7, 0.8, 1.9, 1.2] xopt = fmin(rosen, x0) print xopt |