Skip to content
Snippets Groups Projects
Commit 164fe7e3 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

[stvenant] Add C_program and fix bugs in test_stvenant.py

parent d5e09ab3
No related merge requests found
......@@ -5,8 +5,9 @@ Test if results are identical to the reference data from C version
"""
from stvenant import wL, wR, xi, load_file
from stvenant import riemann_loop, KERNELS
from stvenant import riemann_loop, KERNELS, C_program
from pytest import fixture, mark, param
from numpy.testing import assert_allclose, assert_array_equal
import sys
......@@ -18,8 +19,8 @@ def ref_data():
def test_xi(ref_data):
"""Test if space vector are identical"""
x_ref, h_ref, u_ref = ref_data
assert xi.all() == x_ref.all()
xi_ref, h_ref, u_ref = ref_data
assert_allclose(xi, xi_ref, atol=1e-15)
reason = "Skipped because pythran translation does not work on Mac currently"
......@@ -32,7 +33,17 @@ kernels = [kernel if kernel != "pythran"
def test_loop(ref_data, kernel):
"""Test xi-loop riemann_loop for various implementations of the
riemmann solver function"""
xi_ref, h_ref, u_ref = ref_data
w = riemann_loop(kernel, wL, wR, xi)
assert_allclose(w[:, 0], h_ref, atol=1e-6)
assert_allclose(w[:, 1]/w[:, 0], u_ref, atol=1e-6)
def test_C(ref_data):
"""Test if stvenant.exe produces the same data output"""
x_ref, h_ref, u_ref = ref_data
w = riemann_loop(wL, wR, xi, kernel)
assert w[:, 0].all() == h_ref.all()
assert w[:, 1].all() == u_ref.all()
C_program("./stvenant.exe")
x, h, u = load_file("plotriem")
assert_array_equal(x, x_ref)
assert_array_equal(h, h_ref)
assert_array_equal(u, u_ref)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment