Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_f_params error happens in integrate.complex_ode #4781

Open
foxwb opened this issue Apr 29, 2015 · 1 comment
Open

set_f_params error happens in integrate.complex_ode #4781

foxwb opened this issue Apr 29, 2015 · 1 comment

Comments

@foxwb
Copy link

foxwb commented Apr 29, 2015

The example below was mainly copied from docs.scipy.org, and set_f_params worked well when the solver is integrate.ode, however, if changing ode to integrate.complex_ode, error happened when invoked set_f_params. The enviroment of Python is: Python3.4.3, Scipy0.15

from scipy.integrate import complex_ode
y0, t0 = [1.0j, 2.0], 0
def f(t, y, arg1):
     return [1j*arg1*y[0] + y[1], -arg1*y[1]**2]
def jac(t, y, arg1):
    return [[1j*arg1, 1], [0, -arg1*2*y[1]]]
#r = ode(f, jac).set_integrator('zvode', method='bdf')
r = complex_ode(f, jac)
r.set_initial_value(y0, t0).set_f_params(2.0).set_jac_params(2.0)
t1 = 10
dt = 1
while r.successful() and r.t < t1:
     r.integrate(r.t+dt)
     #print("%g %g" % (r.t, r.y))
     print(r.y);
Error message:
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\aaa.py", line 16, in <module>
    r.integrate(r.t+dt)
  File "C:\Python34\lib\site-packages\scipy\integrate\_ode.py", line 567, in integrate
    y = ode.integrate(self, t, step, relax)
  File "C:\Python34\lib\site-packages\scipy\integrate\_ode.py", line 394, in integrate
    self.f_params, self.jac_params)
  File "C:\Python34\lib\site-packages\scipy\integrate\_ode.py", line 849, in run
    y1, t, istate = self.runner(*args)
  File "C:\Python34\lib\site-packages\scipy\integrate\_ode.py", line 497, in _wrap
    f = self.cf(*((t, y[::2] + 1j * y[1::2]) + f_args))
TypeError: 'float' object is not subscriptable
@tpudlik
Copy link
Contributor

tpudlik commented Oct 10, 2015

Related issue: #1976

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants