Skip to content
Snippets Groups Projects

Reduction Support

Open Richard Angersbach requested to merge rangersbach/reductions into v2.0-dev
Viewing commit 3e595df6
Show latest version
1 file
+ 13
3
Preferences
Compare changes
@@ -5,6 +5,15 @@ import sympy as sp
import pystencils as ps
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("op", ["+", "-", "*", "min", "max"])
@@ -24,6 +33,7 @@ def test_reduction(dtype, op):
ps.show_code(ast_reduction)
array = np.ones((10,), dtype=dtype)
kernel_reduction(x=array, w=0)
# TODO: check if "w = #points"
\ No newline at end of file
array = np.full((SIZE,), INIT, dtype=dtype)
reduction_array = np.zeros(1, dtype=dtype)
kernel_reduction(x=array, w=reduction_array)
assert np.allclose(reduction_array, SOLUTION[op])
\ No newline at end of file