From b45ad7bee5117b1f35bdbc2b9590f2f16881d206 Mon Sep 17 00:00:00 2001 From: PeterMeisrimelModelon <92585725+PeterMeisrimelModelon@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:29:15 +0100 Subject: [PATCH] Unified pylab imports --- examples/cvode_basic.py | 14 +++---- examples/cvode_basic_backward.py | 12 +++--- examples/cvode_gyro.py | 12 +++--- examples/cvode_stability.py | 20 +++++----- examples/cvode_with_disc.py | 12 +++--- examples/cvode_with_initial_sensitivity.py | 38 +++++++++---------- examples/cvode_with_jac.py | 12 +++--- examples/cvode_with_jac_sparse.py | 12 +++--- examples/cvode_with_jac_spgmr.py | 12 +++--- examples/cvode_with_parameters.py | 12 +++--- examples/cvode_with_parameters_fcn.py | 12 +++--- examples/cvode_with_parameters_modified.py | 12 +++--- examples/dasp3_basic.py | 14 +++---- examples/dopri5_basic.py | 12 +++--- examples/dopri5_with_disc.py | 12 +++--- examples/euler_basic.py | 14 +++---- examples/euler_vanderpol.py | 12 +++--- examples/euler_with_disc.py | 12 +++--- examples/glimda_vanderpol.py | 22 +++++------ examples/ida_basic_backward.py | 12 +++--- examples/ida_with_disc.py | 12 +++--- examples/ida_with_initial_sensitivity.py | 38 +++++++++---------- examples/ida_with_jac.py | 12 +++--- examples/ida_with_jac_spgmr.py | 12 +++--- examples/ida_with_parameters.py | 12 +++--- .../ida_with_user_defined_handle_result.py | 24 ++++++------ examples/kinsol_ors.py | 30 +++++++-------- examples/lsodar_bouncing_ball.py | 34 ++++++++--------- examples/lsodar_vanderpol.py | 12 +++--- examples/lsodar_with_disc.py | 12 +++--- examples/radau5dae_time_events.py | 12 +++--- examples/radau5dae_vanderpol.py | 22 +++++------ examples/radau5ode_vanderpol.py | 12 +++--- examples/radau5ode_with_disc.py | 12 +++--- examples/radau5ode_with_disc_sparse.py | 12 +++--- examples/radau5ode_with_jac_sparse.py | 12 +++--- examples/rodasode_vanderpol.py | 12 +++--- examples/rungekutta34_basic.py | 12 +++--- examples/rungekutta34_with_disc.py | 12 +++--- examples/rungekutta4_basic.py | 12 +++--- src/explicit_ode.pyx | 14 +++---- src/implicit_ode.pyx | 36 +++++++++--------- src/lib/radau_core.py | 12 +++--- src/solvers/radar5.py | 16 ++++---- src/solvers/radau5.py | 8 ++-- 45 files changed, 352 insertions(+), 352 deletions(-) diff --git a/examples/cvode_basic.py b/examples/cvode_basic.py index ce56f90c..20c11264 100644 --- a/examples/cvode_basic.py +++ b/examples/cvode_basic.py @@ -57,13 +57,13 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t1, y1, color="b") - P.plot(t2, y2, color="r") - P.title(exp_mod.name) - P.ylabel('y') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t1, y1, color="b") + pl.plot(t2, y2, color="r") + pl.title(exp_mod.name) + pl.ylabel('y') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y2[-1][0], 0.00347746, 5) diff --git a/examples/cvode_basic_backward.py b/examples/cvode_basic_backward.py index 6a546c01..c5454800 100644 --- a/examples/cvode_basic_backward.py +++ b/examples/cvode_basic_backward.py @@ -54,12 +54,12 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t, y, color="b") - P.title(exp_mod.name) - P.ylabel('y') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t, y, color="b") + pl.title(exp_mod.name) + pl.ylabel('y') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0], 4.00000000, 3) diff --git a/examples/cvode_gyro.py b/examples/cvode_gyro.py index 605a152f..eb9590a1 100644 --- a/examples/cvode_gyro.py +++ b/examples/cvode_gyro.py @@ -75,12 +75,12 @@ def f(t, u): # Plot if with_plots: - import pylab as P - P.plot(t, y/10000.) - P.xlabel('Time') - P.ylabel('States, scaled by $10^4$') - P.title(exp_mod.name) - P.show() + import pylab as pl + pl.plot(t, y/10000.) + pl.xlabel('Time') + pl.ylabel('States, scaled by $10^4$') + pl.title(exp_mod.name) + pl.show() #Basic tests nose.tools.assert_almost_equal(y[-1][0], 692.800241862) diff --git a/examples/cvode_stability.py b/examples/cvode_stability.py index 859f5339..4a7a7eaf 100644 --- a/examples/cvode_stability.py +++ b/examples/cvode_stability.py @@ -76,16 +76,16 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.subplot(211) - P.plot(t,y[:,2]) - P.ylabel("State: $y_1$") - P.subplot(212) - P.plot(t,exp_mod.order) - P.ylabel("Order") - P.suptitle(exp_mod.name) - P.xlabel("Time") - P.show() + import pylab as pl + pl.subplot(211) + pl.plot(t,y[:,2]) + pl.ylabel("State: $y_1$") + pl.subplot(212) + pl.plot(t,exp_mod.order) + pl.ylabel("Order") + pl.suptitle(exp_mod.name) + pl.xlabel("Time") + pl.show() #Basic test x1 = y[:,0] diff --git a/examples/cvode_with_disc.py b/examples/cvode_with_disc.py index e2041c53..1752b2cb 100644 --- a/examples/cvode_with_disc.py +++ b/examples/cvode_with_disc.py @@ -148,12 +148,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title(exp_mod.name) - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title(exp_mod.name) + pl.ylabel('States') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0],8.0) diff --git a/examples/cvode_with_initial_sensitivity.py b/examples/cvode_with_initial_sensitivity.py index 8404c55f..848eeb16 100644 --- a/examples/cvode_with_initial_sensitivity.py +++ b/examples/cvode_with_initial_sensitivity.py @@ -88,39 +88,39 @@ def f(t, y, p): #Plot if with_plots: - import pylab as P + import pylab as pl title_text=r"Sensitivity w.r.t. ${}$" legend_text=r"$\mathrm{{d}}{}/\mathrm{{d}}{}$" - P.figure(1) - P.subplot(221) - P.plot(t, np.array(exp_sim.p_sol[0])[:,0], + pl.figure(1) + pl.subplot(221) + pl.plot(t, np.array(exp_sim.p_sol[0])[:,0], t, np.array(exp_sim.p_sol[0])[:,1], t, np.array(exp_sim.p_sol[0])[:,2]) - P.title(title_text.format('p_1')) - P.legend((legend_text.format('y_1','p_1'), + pl.title(title_text.format('p_1')) + pl.legend((legend_text.format('y_1','p_1'), legend_text.format('y_1','p_2'), legend_text.format('y_1','p_3'))) - P.subplot(222) - P.plot(t, np.array(exp_sim.p_sol[1])[:,0], + pl.subplot(222) + pl.plot(t, np.array(exp_sim.p_sol[1])[:,0], t, np.array(exp_sim.p_sol[1])[:,1], t, np.array(exp_sim.p_sol[1])[:,2]) - P.title(title_text.format('p_2')) - P.legend((legend_text.format('y_2','p_1'), + pl.title(title_text.format('p_2')) + pl.legend((legend_text.format('y_2','p_1'), legend_text.format('y_2','p_2'), legend_text.format('y_2','p_3'))) - P.subplot(223) - P.plot(t, np.array(exp_sim.p_sol[2])[:,0], + pl.subplot(223) + pl.plot(t, np.array(exp_sim.p_sol[2])[:,0], t, np.array(exp_sim.p_sol[2])[:,1], t, np.array(exp_sim.p_sol[2])[:,2]) - P.title(title_text.format('p_3')) - P.legend((legend_text.format('y_3','p_1'), + pl.title(title_text.format('p_3')) + pl.legend((legend_text.format('y_3','p_1'), legend_text.format('y_3','p_2'), legend_text.format('y_3','p_3'))) - P.subplot(224) - P.title('ODE Solution') - P.plot(t, y) - P.suptitle(exp_mod.name) - P.show() + pl.subplot(224) + pl.title('ODE Solution') + pl.plot(t, y) + pl.suptitle(exp_mod.name) + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0], 1577.6552477, 5) diff --git a/examples/cvode_with_jac.py b/examples/cvode_with_jac.py index bb34a162..7bb4d1fe 100644 --- a/examples/cvode_with_jac.py +++ b/examples/cvode_with_jac.py @@ -70,12 +70,12 @@ def jac(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y,linestyle="dashed",marker="o") #Plot the solution - P.xlabel('Time') - P.ylabel('State') - P.title(exp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y,linestyle="dashed",marker="o") #Plot the solution + pl.xlabel('Time') + pl.ylabel('State') + pl.title(exp_mod.name) + pl.show() #Basic tests nose.tools.assert_almost_equal(y[-1][0],-121.75000000,4) diff --git a/examples/cvode_with_jac_sparse.py b/examples/cvode_with_jac_sparse.py index bdc745c9..ca0ccb6b 100644 --- a/examples/cvode_with_jac_sparse.py +++ b/examples/cvode_with_jac_sparse.py @@ -85,12 +85,12 @@ def jac(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y[:,1],linestyle="dashed",marker="o") #Plot the solution - P.xlabel('Time') - P.ylabel('State') - P.title(exp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y[:,1],linestyle="dashed",marker="o") #Plot the solution + pl.xlabel('Time') + pl.ylabel('State') + pl.title(exp_mod.name) + pl.show() #Basic tests nose.tools.assert_almost_equal(y[-1][0],0.9851,3) diff --git a/examples/cvode_with_jac_spgmr.py b/examples/cvode_with_jac_spgmr.py index 58f0aa51..3914b901 100644 --- a/examples/cvode_with_jac_spgmr.py +++ b/examples/cvode_with_jac_spgmr.py @@ -77,12 +77,12 @@ def jacv(t,y,fy,v): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.xlabel('Time') - P.ylabel('State') - P.title(exp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y) + pl.xlabel('Time') + pl.ylabel('State') + pl.title(exp_mod.name) + pl.show() #Basic tests nose.tools.assert_almost_equal(y[-1][0],-121.75000000,4) diff --git a/examples/cvode_with_parameters.py b/examples/cvode_with_parameters.py index 177b34ee..9746e1ad 100644 --- a/examples/cvode_with_parameters.py +++ b/examples/cvode_with_parameters.py @@ -79,12 +79,12 @@ def f(t, y, p): #Plot if with_plots: - import pylab as P - P.plot(t, y) - P.title(exp_mod.name) - P.xlabel('Time') - P.ylabel('State') - P.show() + import pylab as pl + pl.plot(t, y) + pl.title(exp_mod.name) + pl.xlabel('Time') + pl.ylabel('State') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0], 9.05518032e-01, 4) diff --git a/examples/cvode_with_parameters_fcn.py b/examples/cvode_with_parameters_fcn.py index f25c448d..ee6156bd 100644 --- a/examples/cvode_with_parameters_fcn.py +++ b/examples/cvode_with_parameters_fcn.py @@ -96,12 +96,12 @@ def fsens(t, y, s, p): #Plot if with_plots: - import pylab as P - P.plot(t, y) - P.title(exp_mod.name) - P.xlabel('Time') - P.ylabel('State') - P.show() + import pylab as pl + pl.plot(t, y) + pl.title(exp_mod.name) + pl.xlabel('Time') + pl.ylabel('State') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0], 9.05518032e-01, 4) diff --git a/examples/cvode_with_parameters_modified.py b/examples/cvode_with_parameters_modified.py index d3288ccc..396b934c 100644 --- a/examples/cvode_with_parameters_modified.py +++ b/examples/cvode_with_parameters_modified.py @@ -77,12 +77,12 @@ def f(t, y, p): #Plot if with_plots: - import pylab as P - P.plot(t, y) - P.xlabel('Time') - P.ylabel('State') - P.title(exp_mod.name) - P.show() + import pylab as pl + pl.plot(t, y) + pl.xlabel('Time') + pl.ylabel('State') + pl.title(exp_mod.name) + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0], 9.05518032e-01, 4) diff --git a/examples/dasp3_basic.py b/examples/dasp3_basic.py index d9b1fbb2..eaa83eed 100644 --- a/examples/dasp3_basic.py +++ b/examples/dasp3_basic.py @@ -91,13 +91,13 @@ def dzdt(t,y,z): #Plot if with_plots: - import pylab as P - P.semilogy(t, y, color="b") - P.grid() - P.title(exp_mod.name+r' $\varepsilon = \frac{1}{3} 10^{-3}$') - P.xlabel('Time') - P.ylabel('y') - P.show() + import pylab as pl + pl.semilogy(t, y, color="b") + pl.grid() + pl.title(exp_mod.name+r' $\varepsilon = \frac{1}{3} 10^{-3}$') + pl.xlabel('Time') + pl.ylabel('y') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1,0], 10.860063849896818, 3) diff --git a/examples/dopri5_basic.py b/examples/dopri5_basic.py index 5ef285e0..413d6a48 100644 --- a/examples/dopri5_basic.py +++ b/examples/dopri5_basic.py @@ -48,12 +48,12 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title(exp_mod.name) - P.xlabel('Time') - P.ylabel('State') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title(exp_mod.name) + pl.xlabel('Time') + pl.ylabel('State') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0],0.02695199,5) diff --git a/examples/dopri5_with_disc.py b/examples/dopri5_with_disc.py index 9f7e45cf..5cf21136 100644 --- a/examples/dopri5_with_disc.py +++ b/examples/dopri5_with_disc.py @@ -147,12 +147,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title(exp_mod.name) - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title(exp_mod.name) + pl.ylabel('States') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0],8.0) diff --git a/examples/euler_basic.py b/examples/euler_basic.py index 6bd2d27d..40de392d 100644 --- a/examples/euler_basic.py +++ b/examples/euler_basic.py @@ -52,13 +52,13 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t1, y1, color="b") - P.plot(t2, y2, color="r") - P.title(exp_mod.name) - P.ylabel('y') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t1, y1, color="b") + pl.plot(t2, y2, color="r") + pl.title(exp_mod.name) + pl.ylabel('y') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y2[-1][0], 0.02628193) diff --git a/examples/euler_vanderpol.py b/examples/euler_vanderpol.py index 0379e8a5..d9212f5a 100644 --- a/examples/euler_vanderpol.py +++ b/examples/euler_vanderpol.py @@ -77,12 +77,12 @@ def jac(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y[:,0], marker='o') - P.title(exp_mod.name) - P.ylabel("State: $y_1$") - P.xlabel("Time") - P.show() + import pylab as pl + pl.plot(t,y[:,0], marker='o') + pl.title(exp_mod.name) + pl.ylabel("State: $y_1$") + pl.xlabel("Time") + pl.show() #Basic test x1 = y[:,0] diff --git a/examples/euler_with_disc.py b/examples/euler_with_disc.py index a6ca36c5..8707ecbc 100644 --- a/examples/euler_with_disc.py +++ b/examples/euler_with_disc.py @@ -144,12 +144,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title("Solution of a differential equation with discontinuities") - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title("Solution of a differential equation with discontinuities") + pl.ylabel('States') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0],8.0) diff --git a/examples/glimda_vanderpol.py b/examples/glimda_vanderpol.py index cc892ad9..834d5181 100644 --- a/examples/glimda_vanderpol.py +++ b/examples/glimda_vanderpol.py @@ -72,17 +72,17 @@ def f(t,y,yd): #Plot if with_plots: - import pylab as P - P.subplot(211) - P.plot(t,y[:,0])#, marker='o') - P.xlabel('Time') - P.ylabel('State') - P.subplot(212) - P.plot(t,yd[:,0]*1.e-5)#, marker='o') - P.xlabel('Time') - P.ylabel('State derivatives scaled with $10^{-5}$') - P.suptitle(imp_mod.name) - P.show() + import pylab as pl + pl.subplot(211) + pl.plot(t,y[:,0])#, marker='o') + pl.xlabel('Time') + pl.ylabel('State') + pl.subplot(212) + pl.plot(t,yd[:,0]*1.e-5)#, marker='o') + pl.xlabel('Time') + pl.ylabel('State derivatives scaled with $10^{-5}$') + pl.suptitle(imp_mod.name) + pl.show() #Basic test x1 = y[:,0] diff --git a/examples/ida_basic_backward.py b/examples/ida_basic_backward.py index be5777a0..e7698879 100644 --- a/examples/ida_basic_backward.py +++ b/examples/ida_basic_backward.py @@ -54,12 +54,12 @@ def f(t,y,yd): #Plot if with_plots: - import pylab as P - P.plot(t, y, color="b") - P.xlabel('Time') - P.ylabel('State') - P.title(imp_mod.name) - P.show() + import pylab as pl + pl.plot(t, y, color="b") + pl.xlabel('Time') + pl.ylabel('State') + pl.title(imp_mod.name) + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0], 4.00000000, 3) diff --git a/examples/ida_with_disc.py b/examples/ida_with_disc.py index 6f3b35fb..1905b66f 100644 --- a/examples/ida_with_disc.py +++ b/examples/ida_with_disc.py @@ -150,12 +150,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title(imp_mod.name) - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title(imp_mod.name) + pl.ylabel('States') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0],8.0) diff --git a/examples/ida_with_initial_sensitivity.py b/examples/ida_with_initial_sensitivity.py index 70dac11e..3081eb45 100644 --- a/examples/ida_with_initial_sensitivity.py +++ b/examples/ida_with_initial_sensitivity.py @@ -87,31 +87,31 @@ def f(t, y, yd,p): #Plot if with_plots: - import pylab as P - P.figure(1) - P.subplot(221) - P.plot(t, np.array(imp_sim.p_sol[0])[:,0], + import pylab as pl + pl.figure(1) + pl.subplot(221) + pl.plot(t, np.array(imp_sim.p_sol[0])[:,0], t, np.array(imp_sim.p_sol[0])[:,1], t, np.array(imp_sim.p_sol[0])[:,2]) - P.title("Parameter p1") - P.legend(("p1/dy1","p1/dy2","p1/dy3")) - P.subplot(222) - P.plot(t, np.array(imp_sim.p_sol[1])[:,0], + pl.title("Parameter p1") + pl.legend(("p1/dy1","p1/dy2","p1/dy3")) + pl.subplot(222) + pl.plot(t, np.array(imp_sim.p_sol[1])[:,0], t, np.array(imp_sim.p_sol[1])[:,1], t, np.array(imp_sim.p_sol[1])[:,2]) - P.title("Parameter p2") - P.legend(("p2/dy1","p2/dy2","p2/dy3")) - P.subplot(223) - P.plot(t, np.array(imp_sim.p_sol[2])[:,0], + pl.title("Parameter p2") + pl.legend(("p2/dy1","p2/dy2","p2/dy3")) + pl.subplot(223) + pl.plot(t, np.array(imp_sim.p_sol[2])[:,0], t, np.array(imp_sim.p_sol[2])[:,1], t, np.array(imp_sim.p_sol[2])[:,2]) - P.title("Parameter p3") - P.legend(("p3/dy1","p3/dy2","p3/dy3")) - P.subplot(224) - P.title('ODE Solution') - P.plot(t, y) - P.suptitle(imp_mod.name) - P.show() + pl.title("Parameter p3") + pl.legend(("p3/dy1","p3/dy2","p3/dy3")) + pl.subplot(224) + pl.title('ODE Solution') + pl.plot(t, y) + pl.suptitle(imp_mod.name) + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0], 1577.6552477,3) diff --git a/examples/ida_with_jac.py b/examples/ida_with_jac.py index 9a92981f..9cfa3027 100644 --- a/examples/ida_with_jac.py +++ b/examples/ida_with_jac.py @@ -114,12 +114,12 @@ def jac(c,t,y,yd): #Plot if with_plots: - import pylab as P - P.plot(t,y,linestyle="dashed",marker="o") #Plot the solution - P.xlabel('Time') - P.ylabel('State') - P.title(imp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y,linestyle="dashed",marker="o") #Plot the solution + pl.xlabel('Time') + pl.ylabel('State') + pl.title(imp_mod.name) + pl.show() return imp_mod, imp_sim diff --git a/examples/ida_with_jac_spgmr.py b/examples/ida_with_jac_spgmr.py index 19e60622..4650a5ae 100644 --- a/examples/ida_with_jac_spgmr.py +++ b/examples/ida_with_jac_spgmr.py @@ -82,12 +82,12 @@ def jacv(t,y,yd,res,v,c): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.xlabel('Time') - P.ylabel('State') - P.title(imp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y) + pl.xlabel('Time') + pl.ylabel('State') + pl.title(imp_mod.name) + pl.show() return imp_mod,imp_sim if __name__=='__main__': diff --git a/examples/ida_with_parameters.py b/examples/ida_with_parameters.py index da28452f..6c5cc9f5 100644 --- a/examples/ida_with_parameters.py +++ b/examples/ida_with_parameters.py @@ -87,12 +87,12 @@ def f(t, y, yd, p): #Plot if with_plots: - import pylab as P - P.plot(t, y) - P.title(imp_mod.name) - P.xlabel('Time') - P.ylabel('State') - P.show() + import pylab as pl + pl.plot(t, y) + pl.title(imp_mod.name) + pl.xlabel('Time') + pl.ylabel('State') + pl.show() return imp_mod, imp_sim diff --git a/examples/ida_with_user_defined_handle_result.py b/examples/ida_with_user_defined_handle_result.py index 9e2d26b2..365305ec 100644 --- a/examples/ida_with_user_defined_handle_result.py +++ b/examples/ida_with_user_defined_handle_result.py @@ -92,19 +92,19 @@ def handle_result(solver, t ,y, yd): #Plot if with_plots: - import pylab as P - P.figure(1) - P.plot(t,y,linestyle="dashed",marker="o") #Plot the solution - P.xlabel('Time') - P.ylabel('State') - P.title(imp_mod.name) + import pylab as pl + pl.figure(1) + pl.plot(t,y,linestyle="dashed",marker="o") #Plot the solution + pl.xlabel('Time') + pl.ylabel('State') + pl.title(imp_mod.name) - P.figure(2) - P.plot([0] + np.add.accumulate(np.diff(t)).tolist(), order) - P.title("Used order during the integration") - P.xlabel("Time") - P.ylabel("Order") - P.show() + pl.figure(2) + pl.plot([0] + np.add.accumulate(np.diff(t)).tolist(), order) + pl.title("Used order during the integration") + pl.xlabel("Time") + pl.ylabel("Order") + pl.show() #Basic tests nose.tools.assert_almost_equal(y[-1][0],0.9401995, places=4) diff --git a/examples/kinsol_ors.py b/examples/kinsol_ors.py index f904ad42..29f263ab 100644 --- a/examples/kinsol_ors.py +++ b/examples/kinsol_ors.py @@ -106,23 +106,23 @@ def setup_param(solver): print("Error (preconditioned), in y: ", np.linalg.norm(y_prec-np.ones(len(y_prec)))) if with_plots: - import pylab as P - P.figure(4) - P.semilogy(alg_solver.get_residual_norm_nonlinear_iterations(), label="Original") - P.semilogy(alg_solver_prec.get_residual_norm_nonlinear_iterations(), label='Preconditioned') - P.xlabel("Number of Iterations") - P.ylabel("Residual Norm") - P.title("Solution Progress") - P.legend() - P.grid() + import pylab as pl + pl.figure(4) + pl.semilogy(alg_solver.get_residual_norm_nonlinear_iterations(), label="Original") + pl.semilogy(alg_solver_prec.get_residual_norm_nonlinear_iterations(), label='Preconditioned') + pl.xlabel("Number of Iterations") + pl.ylabel("Residual Norm") + pl.title("Solution Progress") + pl.legend() + pl.grid() - P.figure(5) - P.plot(y, label="Original") - P.plot(y_prec, label="Preconditioned") - P.legend() - P.grid() + pl.figure(5) + pl.plot(y, label="Original") + pl.plot(y_prec, label="Preconditioned") + pl.legend() + pl.grid() - P.show() + pl.show() #Basic test for j in range(len(y)): diff --git a/examples/lsodar_bouncing_ball.py b/examples/lsodar_bouncing_ball.py index ecba77cb..775c7603 100644 --- a/examples/lsodar_bouncing_ball.py +++ b/examples/lsodar_bouncing_ball.py @@ -131,23 +131,23 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.subplot(221) - P.plot(t,y) - P.title('LSODAR Bouncing ball (one step mode)') - P.ylabel('States: $y$ and $\dot y$') - P.subplot(223) - P.plot(exp_sim.t_sol,exp_sim.h_sol) - P.title('LSODAR step size plot') - P.xlabel('Time') - P.ylabel('Sepsize') - P.subplot(224) - P.plot(exp_sim.t_sol,exp_sim.nq_sol) - P.title('LSODAR order plot') - P.xlabel('Time') - P.ylabel('Order') - P.suptitle(exp_mod.name) - P.show() + import pylab as pl + pl.subplot(221) + pl.plot(t,y) + pl.title('LSODAR Bouncing ball (one step mode)') + pl.ylabel('States: $y$ and $\dot y$') + pl.subplot(223) + pl.plot(exp_sim.t_sol,exp_sim.h_sol) + pl.title('LSODAR step size plot') + pl.xlabel('Time') + pl.ylabel('Sepsize') + pl.subplot(224) + pl.plot(exp_sim.t_sol,exp_sim.nq_sol) + pl.title('LSODAR order plot') + pl.xlabel('Time') + pl.ylabel('Order') + pl.suptitle(exp_mod.name) + pl.show() return exp_mod, exp_sim if __name__=="__main__": diff --git a/examples/lsodar_vanderpol.py b/examples/lsodar_vanderpol.py index 3d19e0e2..ee86735d 100644 --- a/examples/lsodar_vanderpol.py +++ b/examples/lsodar_vanderpol.py @@ -66,12 +66,12 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y[:,0], marker='o') - P.title(exp_mod.name) - P.ylabel("State: $y_1$") - P.xlabel("Time") - P.show() + import pylab as pl + pl.plot(t,y[:,0], marker='o') + pl.title(exp_mod.name) + pl.ylabel("State: $y_1$") + pl.xlabel("Time") + pl.show() #Basic test x1 = y[:,0] diff --git a/examples/lsodar_with_disc.py b/examples/lsodar_with_disc.py index e77e775d..a2952485 100644 --- a/examples/lsodar_with_disc.py +++ b/examples/lsodar_with_disc.py @@ -144,12 +144,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title("Solution of a differential equation with discontinuities") - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title("Solution of a differential equation with discontinuities") + pl.ylabel('States') + pl.xlabel('Time') + pl.show() #Basic test nose.tools.assert_almost_equal(y[-1][0],8.0) diff --git a/examples/radau5dae_time_events.py b/examples/radau5dae_time_events.py index ed6a1cd5..b4b69dd2 100644 --- a/examples/radau5dae_time_events.py +++ b/examples/radau5dae_time_events.py @@ -64,12 +64,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y[:,0], marker='o') - P.xlabel('Time') - P.ylabel('State') - P.title(imp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y[:,0], marker='o') + pl.xlabel('Time') + pl.ylabel('State') + pl.title(imp_mod.name) + pl.show() #Basic test x1 = y[:,0] diff --git a/examples/radau5dae_vanderpol.py b/examples/radau5dae_vanderpol.py index c50cd84b..ea5612ce 100644 --- a/examples/radau5dae_vanderpol.py +++ b/examples/radau5dae_vanderpol.py @@ -72,17 +72,17 @@ def f(t,y,yd): #Plot if with_plots: - import pylab as P - P.subplot(211) - P.plot(t,y[:,0])#, marker='o') - P.xlabel('Time') - P.ylabel('State') - P.subplot(212) - P.plot(t,yd[:,0]*1.e-5)#, marker='o') - P.xlabel('Time') - P.ylabel('State derivatives scaled with $10^{-5}$') - P.suptitle(imp_mod.name) - P.show() + import pylab as pl + pl.subplot(211) + pl.plot(t,y[:,0])#, marker='o') + pl.xlabel('Time') + pl.ylabel('State') + pl.subplot(212) + pl.plot(t,yd[:,0]*1.e-5)#, marker='o') + pl.xlabel('Time') + pl.ylabel('State derivatives scaled with $10^{-5}$') + pl.suptitle(imp_mod.name) + pl.show() #Basic test x1 = y[:,0] diff --git a/examples/radau5ode_vanderpol.py b/examples/radau5ode_vanderpol.py index f425a388..bbc852f9 100644 --- a/examples/radau5ode_vanderpol.py +++ b/examples/radau5ode_vanderpol.py @@ -67,12 +67,12 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y[:,0])#, marker='o') - P.xlabel('Time') - P.ylabel('State') - P.title(exp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y[:,0])#, marker='o') + pl.xlabel('Time') + pl.ylabel('State') + pl.title(exp_mod.name) + pl.show() #Basic test x1 = y[:,0] diff --git a/examples/radau5ode_with_disc.py b/examples/radau5ode_with_disc.py index d4b6f386..544c34f7 100644 --- a/examples/radau5ode_with_disc.py +++ b/examples/radau5ode_with_disc.py @@ -140,12 +140,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title("Solution of a differential equation with discontinuities") - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title("Solution of a differential equation with discontinuities") + pl.ylabel('States') + pl.xlabel('Time') + pl.show() return exp_mod, exp_sim diff --git a/examples/radau5ode_with_disc_sparse.py b/examples/radau5ode_with_disc_sparse.py index 2906f318..9ef1d6f3 100644 --- a/examples/radau5ode_with_disc_sparse.py +++ b/examples/radau5ode_with_disc_sparse.py @@ -148,12 +148,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title("Solution of a differential equation with discontinuities") - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title("Solution of a differential equation with discontinuities") + pl.ylabel('States') + pl.xlabel('Time') + pl.show() return exp_mod, exp_sim diff --git a/examples/radau5ode_with_jac_sparse.py b/examples/radau5ode_with_jac_sparse.py index 54abe28b..633f0535 100644 --- a/examples/radau5ode_with_jac_sparse.py +++ b/examples/radau5ode_with_jac_sparse.py @@ -81,12 +81,12 @@ def jac(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y[:,1],linestyle="dashed",marker="o") #Plot the solution - P.xlabel('Time') - P.ylabel('State') - P.title(exp_mod.name) - P.show() + import pylab as pl + pl.plot(t,y[:,1],linestyle="dashed",marker="o") #Plot the solution + pl.xlabel('Time') + pl.ylabel('State') + pl.title(exp_mod.name) + pl.show() #Basic tests nose.tools.assert_almost_equal(y[-1][0], 0.9851, 3) diff --git a/examples/rodasode_vanderpol.py b/examples/rodasode_vanderpol.py index 61aa5a6d..61da426b 100644 --- a/examples/rodasode_vanderpol.py +++ b/examples/rodasode_vanderpol.py @@ -76,12 +76,12 @@ def jac(t,y): #Plot if with_plots: - import pylab as P - P.plot(t,y[:,0], marker='o') - P.title(exp_mod.name) - P.ylabel("State: $y_1$") - P.xlabel("Time") - P.show() + import pylab as pl + pl.plot(t,y[:,0], marker='o') + pl.title(exp_mod.name) + pl.ylabel("State: $y_1$") + pl.xlabel("Time") + pl.show() #Basic test diff --git a/examples/rungekutta34_basic.py b/examples/rungekutta34_basic.py index 978dbb33..fea7749f 100644 --- a/examples/rungekutta34_basic.py +++ b/examples/rungekutta34_basic.py @@ -53,12 +53,12 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t, y) - P.title(exp_mod.name) - P.ylabel('y') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t, y) + pl.title(exp_mod.name) + pl.ylabel('y') + pl.xlabel('Time') + pl.show() return exp_mod, exp_sim diff --git a/examples/rungekutta34_with_disc.py b/examples/rungekutta34_with_disc.py index 51764300..97e222b7 100644 --- a/examples/rungekutta34_with_disc.py +++ b/examples/rungekutta34_with_disc.py @@ -142,12 +142,12 @@ def run_example(with_plots=True): #Plot if with_plots: - import pylab as P - P.plot(t,y) - P.title(exp_mod.name) - P.ylabel('States') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t,y) + pl.title(exp_mod.name) + pl.ylabel('States') + pl.xlabel('Time') + pl.show() return exp_mod, exp_sim diff --git a/examples/rungekutta4_basic.py b/examples/rungekutta4_basic.py index eaa139e4..cb009129 100644 --- a/examples/rungekutta4_basic.py +++ b/examples/rungekutta4_basic.py @@ -53,12 +53,12 @@ def f(t,y): #Plot if with_plots: - import pylab as P - P.plot(t, y) - P.title(exp_mod.name) - P.ylabel('y') - P.xlabel('Time') - P.show() + import pylab as pl + pl.plot(t, y) + pl.title(exp_mod.name) + pl.ylabel('y') + pl.xlabel('Time') + pl.show() return exp_mod, exp_sim diff --git a/src/explicit_ode.pyx b/src/explicit_ode.pyx index 8712fcac..cb274518 100644 --- a/src/explicit_ode.pyx +++ b/src/explicit_ode.pyx @@ -380,15 +380,15 @@ cdef class Explicit_ODE(ODE): - See http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.plot for information about the available options for **kwargs. """ - import pylab as P + import pylab as pl if len(self.t_sol) > 0: - P.xlabel('time') - P.ylabel('state') - P.title(self.problem.name) + pl.xlabel('time') + pl.ylabel('state') + pl.title(self.problem.name) if not mask: - P.plot(self.t_sol, self.y_sol, **kwargs) + pl.plot(self.t_sol, self.y_sol, **kwargs) else: if not isinstance(mask, list): raise Explicit_ODE_Exception('Mask must be a list of integers') @@ -397,8 +397,8 @@ cdef class Explicit_ODE(ODE): 'the number of variables.') for i in range(len(mask)): if mask[i]: - P.plot(self.t_sol, np.array(self.y_sol)[:,i],**kwargs) + pl.plot(self.t_sol, np.array(self.y_sol)[:,i],**kwargs) - P.show() + pl.show() else: self.log_message("No result for plotting found.",NORMAL) diff --git a/src/implicit_ode.pyx b/src/implicit_ode.pyx index 0fcec740..a2103f11 100644 --- a/src/implicit_ode.pyx +++ b/src/implicit_ode.pyx @@ -445,12 +445,12 @@ cdef class Implicit_ODE(ODE): - See http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.plot for information about the available options for **kwargs. """ - import pylab as P + import pylab as pl if len(self.t_sol) > 0: - P.figure(1) + pl.figure(1) if not mask: - P.plot(self.t_sol, self.y_sol, **kwargs) + pl.plot(self.t_sol, self.y_sol, **kwargs) else: if not isinstance(mask, list): raise Implicit_ODE_Exception('Mask must be a list of integers') @@ -459,21 +459,21 @@ cdef class Implicit_ODE(ODE): 'the number of variables.') for i in range(len(mask)): if mask[i]: - P.plot(self.t_sol, np.array(self.y_sol)[:,i], **kwargs) + pl.plot(self.t_sol, np.array(self.y_sol)[:,i], **kwargs) - P.xlabel('time') - P.ylabel('state') - P.title(self.problem.name) + pl.xlabel('time') + pl.ylabel('state') + pl.title(self.problem.name) if der and not mask: - P.figure(2) - P.plot(self.t_sol, self.yd_sol, **kwargs) - P.xlabel('time') - P.ylabel('state derivatives') - P.title(self.problem.name) + pl.figure(2) + pl.plot(self.t_sol, self.yd_sol, **kwargs) + pl.xlabel('time') + pl.ylabel('state derivatives') + pl.title(self.problem.name) elif mask and der: - P.figure(2) + pl.figure(2) if not isinstance(mask, list): raise Implicit_ODE_Exception('Mask must be a list of integers') if not len(mask)==len(self.yd_sol[-1]): @@ -481,13 +481,13 @@ cdef class Implicit_ODE(ODE): 'the number of variables.') for i in range(len(mask)): if mask[i]: - P.plot(self.t_sol, np.array(self.yd_sol)[:,i], **kwargs) + pl.plot(self.t_sol, np.array(self.yd_sol)[:,i], **kwargs) - P.xlabel('time') - P.ylabel('state derivatives') - P.title(self.problem.name) + pl.xlabel('time') + pl.ylabel('state derivatives') + pl.title(self.problem.name) - P.show() + pl.show() else: self.log_message("No result for plotting found.",NORMAL) diff --git a/src/lib/radau_core.py b/src/lib/radau_core.py index f388b9c2..e207ed2d 100644 --- a/src/lib/radau_core.py +++ b/src/lib/radau_core.py @@ -58,13 +58,13 @@ def plot_stepsize(self): """ Plots the step-size. """ - import pylab as P + import pylab as pl - P.semilogy(np.diff(self.t),drawstyle='steps-post') - P.title(self.problem.name) - P.ylabel('Step length') - P.xlabel('Number of steps') - P.show() + pl.semilogy(np.diff(self.t),drawstyle='steps-post') + pl.title(self.problem.name) + pl.ylabel('Step length') + pl.xlabel('Number of steps') + pl.show() def _set_newt(self, newt): """ diff --git a/src/solvers/radar5.py b/src/solvers/radar5.py index b676bd1a..54c06880 100644 --- a/src/solvers/radar5.py +++ b/src/solvers/radar5.py @@ -17,7 +17,7 @@ import sys import numpy as np -import pylab as P +import pylab as pl from assimulo.ode import NORMAL, ID_PY_COMPLETE, ID_PY_EVENT from assimulo.explicit_ode import Explicit_ODE @@ -51,8 +51,8 @@ def __init__(self, problem): self.options["inith"] = 0.01 self.options["newt"] = 7 #Maximum number of newton iterations self.options["thet"] = 1.e-3 #Boundary for re-calculation of jac -# self.options["fnewt"] = 0.0 #Stopping critera for Newtons Method - self.options["fnewt"] = 0.03 #Stopping critera for Newtons Method +# self.options["fnewt"] = 0.0 #Stopping criteria for Newtons Method + self.options["fnewt"] = 0.03 #Stopping criteria for Newtons Method self.options["quot1"] = 1.0 #Parameters for changing step-size (lower bound) self.options["quot2"] = 1.2 #Parameters for changing step-size (upper bound) self.options["fac1"] = 0.2 #Parameters for step-size selection (lower bound) @@ -374,11 +374,11 @@ def plot_stepsize(self): """ Plots the step-size. """ - P.semilogy(np.diff(self.t),drawstyle='steps-post') - P.title(self.problem.name) - P.ylabel('Step length') - P.xlabel('Number of steps') - P.show() + pl.semilogy(np.diff(self.t),drawstyle='steps-post') + pl.title(self.problem.name) + pl.ylabel('Step length') + pl.xlabel('Number of steps') + pl.show() def _set_newt(self, newt): """ diff --git a/src/solvers/radau5.py b/src/solvers/radau5.py index 5a3695f7..16efa4ce 100644 --- a/src/solvers/radau5.py +++ b/src/solvers/radau5.py @@ -99,7 +99,7 @@ def __init__(self, problem): self.options["inith"] = 0.01 self.options["newt"] = 7 #Maximum number of newton iterations self.options["thet"] = 1.e-3 #Boundary for re-calculation of jac - self.options["fnewt"] = None #Stopping critera for Newtons Method + self.options["fnewt"] = None #Stopping criteria for Newtons Method self.options["quot1"] = 1.0 #Parameters for changing step-size (lower bound) self.options["quot2"] = 1.2 #Parameters for changing step-size (upper bound) self.options["fac1"] = 0.2 #Parameters for step-size selection (lower bound) @@ -454,7 +454,7 @@ def __init__(self, problem): self.options["inith"] = 0.01 self.options["newt"] = 7 #Maximum number of newton iterations self.options["thet"] = 1.e-3 #Boundary for re-calculation of jac - self.options["fnewt"] = 0 #Stopping critera for Newtons Method + self.options["fnewt"] = 0 #Stopping criteria for Newtons Method self.options["quot1"] = 1.0 #Parameters for changing step-size (lower bound) self.options["quot2"] = 1.2 #Parameters for changing step-size (upper bound) self.options["fac1"] = 0.2 #Parameters for step-size selection (lower bound) @@ -972,7 +972,7 @@ def __init__(self, problem): self.options["inith"] = 0.01 self.options["newt"] = 7 #Maximum number of newton iterations self.options["thet"] = 1.e-3 #Boundary for re-calculation of jac - self.options["fnewt"] = 0.0 #Stopping critera for Newtons Method + self.options["fnewt"] = 0.0 #Stopping criteria for Newtons Method self.options["quot1"] = 1.0 #Parameters for changing step-size (lower bound) self.options["quot2"] = 1.2 #Parameters for changing step-size (upper bound) self.options["fac1"] = 0.2 #Parameters for step-size selection (lower bound) @@ -1250,7 +1250,7 @@ def __init__(self, problem): self.options["inith"] = 0.01 self.options["newt"] = 7 #Maximum number of newton iterations self.options["thet"] = 1.e-3 #Boundary for re-calculation of jac - self.options["fnewt"] = 0 #Stopping critera for Newtons Method + self.options["fnewt"] = 0 #Stopping criteria for Newtons Method self.options["quot1"] = 1.0 #Parameters for changing step-size (lower bound) self.options["quot2"] = 1.2 #Parameters for changing step-size (upper bound) self.options["fac1"] = 0.2 #Parameters for step-size selection (lower bound)