Ticket #3935 (closed defect: fixed)

Opened 3 months ago

Last modified 3 months ago

[with patch, positive review] ode_solver __init__ method ignores many parameters

Reported by: jwmerrill Assigned to: jkantor
Priority: major Milestone: sage-3.1.2
Component: numerical Keywords:
Cc:

Description

The following example comes from the in-source documentation for ode_solver:

sage: T = ode_solver()
sage: g_1= lambda t,y: [y[1]*y[2],-y[0]*y[2],-0.51*y[0]*y[1]]
sage: T.function=g_1
sage: T.y_0=[0,1,1]
sage: T.scale_abs=[1e-4,1e-4,1e-5]
sage: T.error_rel=1e-4
sage: T.ode_solve(t_span=[0,12],num_points=100)
sage: f = T.interpolate_solution()
sage: f(pi)              # slightly random precision
0.53794725135406318

It should be possible to set these attributes using arguments to the constructor, but this fails:

sage: T = ode_solver(g_1,y_0=[0,1,1],scale_abs=[1e-4,1e-4,1e-5],error_rel=1e-4)
sage: T.ode_solve(t_span=[0,12],num_points=100)
sage: f = T.interpolate_solution()
sage: f(pi)
Traceback (click to the left for traceback)
...
TypeError: object of type 'NoneType' has no len()

Attachments

ode_solver_patch.patch (2.2 kB) - added by jwmerrill on 08/23/2008 11:39:15 AM.
Adds a doctest and fixes the init method
ode_solver_patch-referee.patch (0.8 kB) - added by jason on 08/27/2008 08:44:03 AM.

Change History

08/23/2008 11:39:15 AM changed by jwmerrill

  • attachment ode_solver_patch.patch added.

Adds a doctest and fixes the init method

08/23/2008 11:41:59 AM changed by jwmerrill

One thing I'm worried about is that the tests for ode.pyx already take a long time (more than two minutes), and this makes them take even longer.

08/23/2008 11:45:59 AM changed by jwmerrill

  • summary changed from ode_solver __init__ method ignores many parameters to [with patch, needs review] ode_solver __init__ method ignores many parameters.

08/27/2008 08:43:29 AM changed by jason

  • summary changed from [with patch, needs review] ode_solver __init__ method ignores many parameters to [with patch, positive review] ode_solver __init__ method ignores many parameters.

This seems to work and doctests pass. However, the given example is not the same as the example before (as the docs claim), since the algorithm used is different. The referee patch adds an algorithm keyword to make it the same. Apply the referee patch after the original patch and then it is positive review.

08/27/2008 08:44:03 AM changed by jason

  • attachment ode_solver_patch-referee.patch added.

08/27/2008 08:49:49 AM changed by jason

jwmerrill, related to the docs of ode_solver, could you review #3966? Thanks.

08/27/2008 03:08:33 PM changed by mabshoff

  • status changed from new to closed.
  • resolution set to fixed.

Merged both patches in Sage 3.1.2.alpha2