From 3e595df6c79cc1a7a8c2ff4ab86825e81aadbf43 Mon Sep 17 00:00:00 2001
From: zy69guqi <richard.angersbach@fau.de>
Date: Wed, 22 Jan 2025 17:35:50 +0100
Subject: [PATCH] Refine test_reduction.py to check for result correctness

---
 tests/kernelcreation/test_reduction.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tests/kernelcreation/test_reduction.py b/tests/kernelcreation/test_reduction.py
index c41d250f4..b97343e72 100644
--- a/tests/kernelcreation/test_reduction.py
+++ b/tests/kernelcreation/test_reduction.py
@@ -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
-- 
GitLab