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

MAINT: in integrate.ode, generate understandable error for f2py issue. #395

Merged
merged 1 commit into from Feb 5, 2013

Commits on Jan 5, 2013

  1. MAINT: in integrate.ode, generate understandable error for f2py issue.

    Closes ticket 1187.  Note that this cannot be tested without a warning message
    being printed by vodemodule.c, even when redirecting stderr::
    
        import sys
        from scipy import integrate
    
        class RedirectStdStreams(object):
            def __init__(self, stdout=None, stderr=None):
                self._stdout = stdout or sys.stdout
                self._stderr = stderr or sys.stderr
    
            def __enter__(self):
                self.old_stdout, self.old_stderr = sys.stdout, sys.stderr
                self.old_stdout.flush(); self.old_stderr.flush()
                sys.stdout, sys.stderr = self._stdout, self._stderr
    
            def __exit__(self, exc_type, exc_value, traceback):
                self._stdout.flush(); self._stderr.flush()
                sys.stdout = self.old_stdout
    
        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]]]
    
        with RedirectStdStreams():
            r = integrate.ode(f, jac).set_integrator('zvode', method='bdf', with_jacobian=True)
            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)
    rgommers committed Jan 5, 2013
    Copy the full SHA
    d567f79 View commit details
    Browse the repository at this point in the history