Skip to content
Browse files

Merge pull request #395 from rgommers/ticket-1187-ode-error

BUG: integrate: in ode, generate understandable error for f2py issue
  • Loading branch information...
2 parents 3a2de53 + d567f79 commit 96b3dbed93f66d96932ab3a6f930fe78c69653ad @pv pv committed Feb 5, 2013
Showing with 10 additions and 3 deletions.
  1. +10 −3 scipy/integrate/_ode.py
View
13 scipy/integrate/_ode.py
@@ -111,6 +111,7 @@ class ode(object):
f : callable ``f(t, y, *f_args)``
Rhs of the equation. t is a scalar, ``y.shape == (n,)``.
``f_args`` is set by calling ``set_f_params(*args)``.
+ `f` should return a scalar, array or list (not a tuple).
jac : callable ``jac(t, y, *jac_args)``
Jacobian of the rhs, ``jac[i,j] = d f[i] / d y[j]``.
``jac_args`` is set by calling ``set_f_params(*args)``.
@@ -378,9 +379,15 @@ def integrate(self, t, step=0, relax=0):
mth = self._integrator.run_relax
else:
mth = self._integrator.run
- self._y, self.t = mth(self.f, self.jac or (lambda: None),
- self._y, self.t, t,
- self.f_params, self.jac_params)
+
+ try:
+ self._y, self.t = mth(self.f, self.jac or (lambda: None),
+ self._y, self.t, t,
+ self.f_params, self.jac_params)
+ except SystemError:
+ # f2py issue with tuple returns, see ticket 1187.
+ raise ValueError('Function to integrate must not return a tuple.')
+
return self._y
def successful(self):

0 comments on commit 96b3dbe

Please sign in to comment.
Something went wrong with that request. Please try again.