changeset 22647:cf8ec7abb4ae stable

Clean up demo and test blocks for ode functions. * ode23.m, ode45.m: Re-order code in %!demo for better appearance when executed. * odeget.m: Use '##' in demo blocks for whole-line comments. Disable "Octave:invalid-input-arg" temporarily when testing unknown option. odeset.m: Use '##' in demo blocks for whole-line comments. Disable "Octave:invalid-input-arg" temporarily when testing unknown option. Fix BIST test that was incorrect now that MassConstant has been removed.
author Rik <rik@octave.org>
date Wed, 19 Oct 2016 14:34:15 -0700
parents 5aa36731a304
children 9bc03a3f7a34
files scripts/ode/ode23.m scripts/ode/ode45.m scripts/ode/odeget.m scripts/ode/odeset.m
diffstat 4 files changed, 23 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ode/ode23.m	Wed Oct 19 14:08:37 2016 -0700
+++ b/scripts/ode/ode23.m	Wed Oct 19 14:34:15 2016 -0700
@@ -296,9 +296,6 @@
 %!   err(i) = norm (y .* exp (t) - 1, Inf);
 %! endfor
 %!
-%! ## Estimate order numerically
-%! p = diff (log (err)) ./ diff (log (h))
-%!
 %! ## Estimate order visually
 %! loglog (h, tol, "-ob",
 %!         h, err, "-b",
@@ -310,6 +307,9 @@
 %! title ("Convergence plot for ode23");
 %! legend ("imposed tolerance", "ode23 (relative) error",
 %!         "order 2", "order 3", "location", "northwest");
+%!
+%! ## Estimate order numerically
+%! p = diff (log (err)) ./ diff (log (h))
 
 ## We are using the "Van der Pol" implementation for all tests that are done
 ## for this function.
--- a/scripts/ode/ode45.m	Wed Oct 19 14:08:37 2016 -0700
+++ b/scripts/ode/ode45.m	Wed Oct 19 14:34:15 2016 -0700
@@ -287,9 +287,6 @@
 %!   err(i) = norm (y .* exp (t) - 1, Inf);
 %! endfor
 %!
-%! ## Estimate order numerically
-%! p = diff (log (err)) ./ diff (log (h))
-%!
 %! ## Estimate order visually
 %! loglog (h, tol, "-ob",
 %!         h, err, "-b",
@@ -301,6 +298,9 @@
 %! title ("Convergence plot for ode45");
 %! legend ("imposed tolerance", "ode45 (relative) error",
 %!         "order 4", "order 5", "location", "northwest");
+%!
+%! ## Estimate order numerically
+%! p = diff (log (err)) ./ diff (log (h))
 
 ## We are using the Van der Pol equation for all tests that are done
 ## for this function.
--- a/scripts/ode/odeget.m	Wed Oct 19 14:08:37 2016 -0700
+++ b/scripts/ode/odeget.m	Wed Oct 19 14:34:15 2016 -0700
@@ -56,9 +56,9 @@
 
 
 %!demo
-%! # Return the manually changed value RelTol of the ODE options
-%! # structure A.  If RelTol wouldn't have been changed then an
-%! # empty matrix value would have been returned.
+%! ## Return the manually changed value RelTol of the ODE options
+%! ## structure A.  If RelTol wouldn't have been changed then an
+%! ## empty matrix value would have been returned.
 %!
 %! A = odeset ("RelTol", 1e-1, "AbsTol", 1e-2);
 %! odeget (A, "RelTol", [])
@@ -71,7 +71,9 @@
 %!assert (odeget (odeset (), "Mass"), [])
 %!assert (odeget (odeset (), "AbsTol", 1e-9), 1e-9)
 %!assert (odeget (odeset ("AbsTol", 1e-9), "AbsTol", []), 1e-9)
-%!assert (odeget (odeset ("foo", 42), "foo"), 42)
+%!test
+%! warning ("off", "Octave:invalid-input-arg", "local");
+%! assert (odeget (odeset ("foo", 42), "foo"), 42);
 
 %!error odeget ()
 %!error odeget (1)
--- a/scripts/ode/odeset.m	Wed Oct 19 14:08:37 2016 -0700
+++ b/scripts/ode/odeset.m	Wed Oct 19 14:34:15 2016 -0700
@@ -232,19 +232,19 @@
 
 
 %!demo
-%! # A new ODE options structure with default values is created.
+%! ## A new ODE options structure with default values is created.
 %!
 %! odeoptA = odeset ();
 
 %!demo
-%! # A new ODE options structure with manually set options
-%! # for "AbsTol" and "RelTol" is created.
+%! ## A new ODE options structure with manually set options
+%! ## for "AbsTol" and "RelTol" is created.
 %!
 %! odeoptB = odeset ("AbsTol", 1e-2, "RelTol", 1e-1);
 
 %!demo
-%! # A new ODE options structure is created from odeoptB with
-%! # a modified value for option "NormControl".
+%! ## A new ODE options structure is created from odeoptB with
+%! ## a modified value for option "NormControl".
 %!
 %! odeoptB = odeset ("AbsTol", 1e-2, "RelTol", 1e-1);
 %! odeoptC = odeset (odeoptB, "NormControl", "on");
@@ -252,7 +252,7 @@
 %!test
 %! odeoptA = odeset ();
 %! assert (isstruct (odeoptA));
-%! assert (numfields (odeoptA), 23);
+%! assert (numfields (odeoptA), 22);
 %! assert (all (structfun ("isempty", odeoptA)));
 
 %!shared odeoptB, odeoptC
@@ -272,13 +272,9 @@
 
 ## Test custom user-defined option
 %!test
-%! wstate = warning ("off", "Octave:invalid-input-arg");
-%! unwind_protect
-%!   odeopt = odeset ("NewtonTol", 3);
-%!   assert (odeopt.NewtonTol, 3);
-%! unwind_protect_cleanup
-%!   warning (wstate);
-%! end_unwind_protect
+%! warning ("off", "Octave:invalid-input-arg", "local");
+%! odeopt = odeset ("NewtonTol", 3);
+%! assert (odeopt.NewtonTol, 3);
 
 ## FIXME: Add an inexact match option once it is available in inputParser.
 ## See bug #49364.
@@ -287,12 +283,7 @@
 
 ## Test input validation
 %!error <argument 'OPT1' is not a valid parameter> odeset ("opt1")
-%!error  odeset (1, 1)
+%!error odeset (1, 1)
 %!error <argument 'OPT1' is not a valid parameter> odeset (odeset (), "opt1")
-%!error  odeset (odeset (), 1, 1)
+%!error odeset (odeset (), 1, 1)
 
-##FIXME: Add not exact match option
-## %!warning <no exact match for 'Rel'.  Assuming 'RelTol'> odeset ("Rel", 1);
-## %!error <Possible fields found: InitialSlope, InitialStep> odeset ("Initial", 1)
-
-