Skip to content
Snippets Groups Projects
Commit 3e595df6 authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Refine test_reduction.py to check for result correctness

parent ba697180
No related branches found
No related tags found
1 merge request!438Reduction Support
...@@ -5,6 +5,15 @@ import sympy as sp ...@@ -5,6 +5,15 @@ import sympy as sp
import pystencils as ps import pystencils as ps
from pystencils.sympyextensions import reduced_assign from pystencils.sympyextensions import reduced_assign
INIT=2
SIZE=15
SOLUTION = {
"+": INIT * SIZE,
"-": INIT * -SIZE,
"*": INIT**SIZE,
"min": INIT,
"max": INIT
}
@pytest.mark.parametrize('dtype', ["float64"]) @pytest.mark.parametrize('dtype', ["float64"])
@pytest.mark.parametrize("op", ["+", "-", "*", "min", "max"]) @pytest.mark.parametrize("op", ["+", "-", "*", "min", "max"])
...@@ -24,6 +33,7 @@ def test_reduction(dtype, op): ...@@ -24,6 +33,7 @@ def test_reduction(dtype, op):
ps.show_code(ast_reduction) ps.show_code(ast_reduction)
array = np.ones((10,), dtype=dtype) array = np.full((SIZE,), INIT, dtype=dtype)
kernel_reduction(x=array, w=0) reduction_array = np.zeros(1, dtype=dtype)
# TODO: check if "w = #points" kernel_reduction(x=array, w=reduction_array)
\ No newline at end of file assert np.allclose(reduction_array, SOLUTION[op])
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment