From faf5a9aa278270f43a3cfef8f92e531ca2af1d5e Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Fri, 20 Dec 2019 14:17:35 +0100
Subject: [PATCH] Add 3d morphology test

---
 tests/test_morphology.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tests/test_morphology.py b/tests/test_morphology.py
index bb82415..6426cdc 100644
--- a/tests/test_morphology.py
+++ b/tests/test_morphology.py
@@ -25,10 +25,17 @@ except ImportError:  # NOQA
 
 
 def test_morphology():
-    x, y = pystencils.fields('x,y: uint8[2d]')
-    x_array = np.random.rand(20, 23, 25).astype(np.uint8)
-    y_array = np.random.rand(20, 23, 25).astype(np.uint8)
-    # TODO
+    import pytest
+    pytest.importorskip("pycuda")
+    from pycuda.gpuarray import to_gpu, zeros_like
+    x = to_gpu((np.random.rand(21, 23, 25) > 0.9).astype(np.uint8))
+    y = zeros_like(x)
+
+    dilation = pystencils_reco.morphology.binary_dilation(x, y, BallStencil(1, ndim=3)).compile()
+
+    for _ in range(1000000):
+        dilation(x=x, y=y)
+        x, y = y, x
 
 
 def test_visualize_morphology():
-- 
GitLab