diff --git a/comparison_fixtures.py b/comparison_fixtures.py deleted file mode 100644 index 04c743236fc597b1ec48ed24d5974360e6da6c7e..0000000000000000000000000000000000000000 --- a/comparison_fixtures.py +++ /dev/null @@ -1,20 +0,0 @@ -import numpy as np -from pytest import approx - - -def arrays(a, b): - assert a == approx(b) - - -def roe_identity(states, R, Rinv): - dState = states[:,1] - states[:,0] - arrays(R@(Rinv@dState), dState) - - -def roe_property(states, fluxes, R, Rinv, lam): - dState = states[:,1] - states[:,0] - dFlux = fluxes[:,1] - fluxes[:,0] - - temp = Rinv@dState - temp = np.multiply(lam, temp) - arrays(R@temp, dFlux) diff --git a/test.py b/test.py index e97a3452d62ecd98bc2c68f902bd64b57c77cdbc..d48f18a3be1c9ddc0992cdec81c4d5b8f5e3f5cf 100644 --- a/test.py +++ b/test.py @@ -1,7 +1,16 @@ +import numpy as np +import numpy.linalg as la +import pyopencl as cl +import pyopencl.array # noqa +import pyopencl.tools # noqa +import pyopencl.clrandom # noqa +import loopy as lp # noqa + import sys import logging import pytest +from pytest import approx import pyopencl as cl from pyopencl.tools import ( # noqa pytest_generate_tests_for_pyopencl @@ -12,7 +21,25 @@ import program_fixtures as program import transform_fixtures as transform import setup_fixtures as setup import kernel_fixtures as kernel -import comparison_fixtures as compare + + +def compare_arrays(a, b): + assert a == approx(b) + + +def compare_roe_identity(states, R, Rinv): + dState = states[:,1] - states[:,0] + compare_arrays(R@(Rinv@dState), dState) + + +def compare_roe_property(states, fluxes, R, Rinv, lam): + dState = states[:,1] - states[:,0] + dFlux = fluxes[:,1] - fluxes[:,0] + + temp = Rinv@dState + temp = np.multiply(lam, temp) + compare_arrays(R@temp, dFlux) + @pytest.mark.xfail @pytest.mark.parametrize("states_str,fluxes_str,direction", [ @@ -35,10 +62,10 @@ def test_roe_uniform_grid(ctx_factory, states_str, fluxes_str, direction): metrics_frozen = setup.identity(params.ndim) R, Rinv, lam = kernel.roe_eigensystem(queue, prg, params, states, metrics_frozen) - compare.roe_identity(states, R, Rinv) + compare_roe_identity(states, R, Rinv) fluxes = setup.array_from_string(fluxes_str) - compare.roe_property(states, fluxes, R, Rinv, lam) + compare_roe_property(states, fluxes, R, Rinv, lam) def test_matvec(ctx_factory): @@ -50,7 +77,7 @@ def test_matvec(ctx_factory): c = kernel.mult_mat_vec(queue, prg, alpha=1.0, a=a, b=b) - compare.arrays(a@b, c) + compare_arrays(a@b, c) #@pytest.mark.slow