Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
Cleanup

removed pytest as requirement from examples

Removing tests from the Assimulo installation

Adding pytest config; adjusted instructions

simplified workflow file

Changed if in test to skipif

Added missing reason in skipif
  • Loading branch information
Peter Meisrimel authored and Peter Meisrimel committed Nov 14, 2024
1 parent 2d1bd56 commit b40b609
Show file tree
Hide file tree
Showing 52 changed files with 116 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
- name: Build
run: python3 setup.py install --user --sundials-home=/usr --blas-home=/usr/lib/x86_64-linux-gnu/ --lapack-home=/usr/lib/x86_64-linux-gnu/ --superlu-home=/usr
- name: Test
run: pytest --verbose tests/
run: pytest
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
--- CHANGELOG ---

--- Assimulo-3.5.x ---
--- Assimulo-FUTURE---
* Added get_sundials_version function (import from assimulo.solvers.sundials).
* Fixed bug that Radau5ODE would not count state events in statistics.
* Removed tests from the Assimulo installation.
* Changed testing framework from `nose` to `pytest`.

--- Assimulo-3.5.2 ---
* Allow to build without distutils for Python>=3.12 support
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Installation is performed using the command:
'python setup.py install --sundials-home=/path/to/sundials --blas-home=/path/to/blas --lapack-home=/path/to/lapack'

Assimulo is then installed under Python dist-packages.
To test the installation, run "pytest tests/".
To test the installation, run "pytest".

For more information regarding Assimulo and the installation procedure,
please visit: http://www.jmodelica.org/assimulo
4 changes: 2 additions & 2 deletions doc/sphinx/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ the section troubleshooting see :ref:`instTrouble` should be consulted before in

.. note::

To test Assimulo, go into the tests folder and type::
To test Assimulo, type::
pytest .
pytest
Which requires pytest.

Expand Down
5 changes: 2 additions & 3 deletions examples/cvode_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -66,8 +65,8 @@ def f(t,y):
pl.show()

#Basic test
assert y2[-1][0] == pytest.approx(0.00347746, abs = 1e-5)
assert exp_sim.get_last_step() == pytest.approx(0.0222169642893, abs = 1e-3)
assert abs(y2[-1][0] - 0.00347746) < 1e-5
assert abs(exp_sim.get_last_step() - 0.0222169642893) < 1e-3

return exp_mod, exp_sim

Expand Down
3 changes: 1 addition & 2 deletions examples/cvode_basic_backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -62,7 +61,7 @@ def f(t,y):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(4.00000000, abs = 1e-3)
assert abs(y[-1][0] - 4.0) < 1e-3

return exp_mod, exp_sim

Expand Down
5 changes: 2 additions & 3 deletions examples/cvode_gyro.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.problem import Explicit_Problem
from assimulo.solvers import CVode

Expand Down Expand Up @@ -83,8 +82,8 @@ def f(t, u):
pl.show()

#Basic tests
assert y[-1][0] == pytest.approx(692.800241862)
assert y[-1][8] == pytest.approx(7.08468221e-1)
assert abs(y[-1][0] - 692.800241862) < 1e-6
assert abs(y[-1][8] - 7.08468221e-1) < 1e-6

return exp_mod, exp_sim

Expand Down
1 change: 0 additions & 1 deletion examples/cvode_stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down
7 changes: 3 additions & 4 deletions examples/cvode_with_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -156,9 +155,9 @@ def run_example(with_plots=True):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(8.0)
assert y[-1][1] == pytest.approx(3.0)
assert y[-1][2] == pytest.approx(2.0)
assert abs(y[-1][0] - 8.0) < 1e-6
assert abs(y[-1][1] - 3.0) < 1e-6
assert abs(y[-1][2] - 2.0) < 1e-6

return exp_mod, exp_sim

Expand Down
9 changes: 4 additions & 5 deletions examples/cvode_with_initial_sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -123,10 +122,10 @@ def f(t, y, p):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(1577.6552477, abs = 1e-5)
assert y[-1][1] == pytest.approx(611.9574565, abs = 1e-5)
assert y[-1][2] == pytest.approx(2215.88563217, abs = 1e-5)
assert exp_sim.p_sol[0][1][0] == pytest.approx(1.0)
assert abs(y[-1][0] - 1577.6552477) < 1e-5
assert abs(y[-1][1] - 611.9574565) < 1e-5
assert abs(y[-1][2] - 2215.88563217) < 1e-5
assert abs(exp_sim.p_sol[0][1][0] - 1.0) < 1e-6

return exp_mod, exp_sim

Expand Down
5 changes: 2 additions & 3 deletions examples/cvode_with_jac.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -78,8 +77,8 @@ def jac(t,y):
pl.show()

#Basic tests
assert y[-1][0] == pytest.approx(-121.75000000, abs = 1e-4)
assert y[-1][1] == pytest.approx(-49.100000000)
assert abs(y[-1][0] + 121.75000000) < 1e-4
assert abs(y[-1][1] + 49.100000000) < 1e-6

return exp_mod, exp_sim

Expand Down
3 changes: 1 addition & 2 deletions examples/cvode_with_jac_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import numpy as np
import scipy.sparse as sps
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -93,7 +92,7 @@ def jac(t,y):
pl.show()

#Basic tests
assert y[-1][0] == pytest.approx(0.9851, abs = 1e-3)
assert abs(y[-1][0] - 0.9851) < 1e-3

return exp_mod, exp_sim

Expand Down
5 changes: 2 additions & 3 deletions examples/cvode_with_jac_spgmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -85,8 +84,8 @@ def jacv(t,y,fy,v):
pl.show()

#Basic tests
assert y[-1][0] == pytest.approx(-121.75000000, abs = 1e-4)
assert y[-1][1] == pytest.approx(-49.100000000)
assert abs(y[-1][0] + 121.75000000) < 1e-4
assert abs(y[-1][1] + 49.100000000) < 1e-6

return exp_mod, exp_sim

Expand Down
14 changes: 7 additions & 7 deletions examples/cvode_with_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -87,12 +86,13 @@ def f(t, y, p):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(9.05518032e-01, abs = 1e-4)
assert y[-1][1] == pytest.approx(2.24046805e-05, abs = 1e-4)
assert y[-1][2] == pytest.approx(9.44595637e-02, abs = 1e-4)
assert exp_sim.p_sol[0][-1][0] == pytest.approx(-1.8761, abs = 1e-2) #Values taken from the example in Sundials
assert exp_sim.p_sol[1][-1][0] == pytest.approx(2.9614e-06, abs = 1e-8)
assert exp_sim.p_sol[2][-1][0] == pytest.approx(-4.9334e-10, abs = 1e-12)
assert abs(y[-1][0] - 9.05518032e-01) < 1e-4
assert abs(y[-1][1] - 2.24046805e-05) < 1e-4
assert abs(y[-1][2] - 9.44595637e-02) < 1e-4
# Values taken from the example in Sundials
assert abs(exp_sim.p_sol[0][-1][0] + 1.8761) < 1e-2
assert abs(exp_sim.p_sol[1][-1][0] - 2.9614e-06) < 1e-8
assert abs(exp_sim.p_sol[2][-1][0] + 4.9334e-10) < 1e-12

return exp_mod, exp_sim

Expand Down
14 changes: 7 additions & 7 deletions examples/cvode_with_parameters_fcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -104,12 +103,13 @@ def fsens(t, y, s, p):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(9.05518032e-01, abs = 1e-4)
assert y[-1][1] == pytest.approx(2.24046805e-05, abs = 1e-4)
assert y[-1][2] == pytest.approx(9.44595637e-02, abs = 1e-4)
assert exp_sim.p_sol[0][-1][0] == pytest.approx(-1.8761, abs = 1e-2) #Values taken from the example in Sundials
assert exp_sim.p_sol[1][-1][0] == pytest.approx(2.9614e-06, abs = 1e-8)
assert exp_sim.p_sol[2][-1][0] == pytest.approx(-4.9334e-10, abs = 1e-12)
assert abs(y[-1][0] - 9.05518032e-01) < 1e-4
assert abs(y[-1][1] - 2.24046805e-05) < 1e-4
assert abs(y[-1][2] - 9.44595637e-02) < 1e-4
#Values taken from the example in Sundials
assert abs(exp_sim.p_sol[0][-1][0] + 1.8761) < 1e-2
assert abs(exp_sim.p_sol[1][-1][0] - 2.9614e-06) < 1e-8
assert abs(exp_sim.p_sol[2][-1][0] + 4.9334e-10) < 1e-12

return exp_mod, exp_sim

Expand Down
12 changes: 6 additions & 6 deletions examples/cvode_with_parameters_modified.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -85,11 +84,12 @@ def f(t, y, p):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(9.05518032e-01, abs = 1e-4)
assert y[-1][1] == pytest.approx(2.24046805e-05, abs = 1e-4)
assert y[-1][2] == pytest.approx(9.44595637e-02, abs = 1e-4)
assert exp_sim.p_sol[0][-1][0] == pytest.approx(-1.8761, abs = 1e-2) #Values taken from the example in Sundials
assert exp_sim.p_sol[1][-1][0] == pytest.approx(2.9614e-06, abs = 1e-8)
assert abs(y[-1][0] - 9.05518032e-01) < 1e-4
assert abs(y[-1][1] - 2.24046805e-05) < 1e-4
assert abs(y[-1][2] - 9.44595637e-02) < 1e-4
# Values taken from the example in Sundials
assert abs(exp_sim.p_sol[0][-1][0] + 1.8761) < 1e-2
assert abs(exp_sim.p_sol[1][-1][0] - 2.9614e-06) < 1e-8

return exp_mod, exp_sim

Expand Down
5 changes: 2 additions & 3 deletions examples/cvode_with_preconditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"""

import numpy as np
import pytest
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -107,8 +106,8 @@ def prec_solve(t, y, fy, r, gamma, delta, data):
exp_sim.plot()

#Basic verification
assert y[-1,0] == pytest.approx(3.11178295, abs = 1e-4)
assert y[-1,1] == pytest.approx(3.19318992, abs = 1e-4)
assert abs(y[-1,0] - 3.11178295) < 1e-4
assert abs(y[-1,1] - 3.19318992) < 1e-4

return exp_mod, exp_sim

Expand Down
3 changes: 1 addition & 2 deletions examples/dasp3_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest

try:
from assimulo.solvers import DASP3ODE
Expand Down Expand Up @@ -100,7 +99,7 @@ def dzdt(t,y,z):
pl.show()

#Basic test
assert y[-1,0] == pytest.approx( 10.860063849896818, abs = 1e-3)
assert abs(y[-1,0] - 10.860063849896818) < 1e-3

return exp_mod, exp_sim

Expand Down
3 changes: 1 addition & 2 deletions examples/dopri5_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import Dopri5
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -56,7 +55,7 @@ def f(t,y):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(0.02695199, abs = 1e-5)
assert abs(y[-1][0] - 0.02695199) < 1e-5

return exp_mod, exp_sim

Expand Down
7 changes: 3 additions & 4 deletions examples/dopri5_with_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import Dopri5
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -155,9 +154,9 @@ def run_example(with_plots=True):
pl.show()

#Basic test
assert y[-1][0] == pytest.approx(8.0)
assert y[-1][1] == pytest.approx(3.0)
assert y[-1][2] == pytest.approx(2.0)
assert abs(y[-1][0] - 8.0) < 1e-6
assert abs(y[-1][1] - 3.0) < 1e-6
assert abs(y[-1][2] - 2.0) < 1e-6

return exp_mod, exp_sim

Expand Down
3 changes: 1 addition & 2 deletions examples/euler_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import ExplicitEuler
from assimulo.problem import Explicit_Problem

Expand Down Expand Up @@ -61,7 +60,7 @@ def f(t,y):
pl.show()

#Basic test
assert y2[-1][0] == pytest.approx(0.02628193)
assert abs(y2[-1][0] - 0.02628193) < 1e-6

return exp_mod, exp_sim

Expand Down
1 change: 0 additions & 1 deletion examples/euler_vanderpol.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import numpy as np
import pytest
from assimulo.solvers import ImplicitEuler
from assimulo.problem import Explicit_Problem

Expand Down
Loading

0 comments on commit b40b609

Please sign in to comment.