[Scipy-tickets] [SciPy] #1451: Wrapper class 'integrate.complex_ode' does not accept function parameters

SciPy Trac scipy-tickets@scipy....
Wed Jun 1 14:31:05 CDT 2011


#1451: Wrapper class 'integrate.complex_ode' does not accept function parameters
--------------------------------------------+-------------------------------
 Reporter:  gideon                          |       Owner:  somebody
     Type:  defect                          |      Status:  new     
 Priority:  highest                         |   Milestone:          
Component:  scipy.integrate                 |     Version:  0.9.0   
 Keywords:  complex_ode, not subscriptable  |  
--------------------------------------------+-------------------------------
 Hi,
 I have tried to use 'integrate.complex_ode' in conjunction with
 integrator.set_f_params(*args). I consistently get the message:
 "'float' object is not subscriptable" (or 'int' or 'complex' depending on
 the parameters passed). This happens whether *args is one parameter or a
 list. Error seems to be in :


 {{{
 /usr/lib/python2.7/dist-packages/scipy/integrate/ode.py in:

 _wrap(self, t, y, *f_args)

     370     def _wrap(self, t, y, *f_args):
 --> 371         f = self.cf(*((t, y[::2] + 1j*y[1::2]) + f_args))
     372         self.tmp[::2] = real(f)
     373         self.tmp[1::2] = imag(f)


 }}}

 The wrapper complex_ode seems to work fine without trying to pass any
 additional function parameters.

 Code to show problem:
 ---------------------

 {{{
 from scipy import integrate
 from pylab import *

 def f(t, y, arg):
         f = -1j*arg*exp(1j*pi)*y
         return f


 ic = [1.0]
 t0 = -.015
 t1 = .015
 dt = 0.1

 solver = integrate.complex_ode(f)
 solver.set_integrator('vode',method='bdf',rtol=1.e-12)
 solver.set_f_params(arg)

 t = []
 sol = []
 solver.set_initial_value(ic, t0)
 while solver.successful() and solver.t < t1:
     solver.integrate(t1,step=1)
     t.append(solver.t)
     sol.append(solver.y)
 print solver.y
 t = array(t)
 sol = array(sol)
 plot(t,abs(sol))

 }}}


 I am running:[[BR]]

 * Linux 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686
 i686 i386 GNU/Linux

 * Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)

 *IPython 0.10.1

 Thanks[[BR]]

 -Gideon

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1451>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list