From aa23450d0a20f8ccbf56467dc51d94fa77ac69a3 Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni <kaushikcfd@gmail.com> Date: Mon, 19 Jul 2021 16:13:43 -0500 Subject: [PATCH] test actx.compile with python scalars --- test/test_arraycontext.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py index 5bb9fb7..0f24cbe 100644 --- a/test/test_arraycontext.py +++ b/test/test_arraycontext.py @@ -891,6 +891,24 @@ def test_actx_compile(actx_factory): np.testing.assert_allclose(result.u, -3.14*v_y) np.testing.assert_allclose(result.v, 3.14*v_x) + +def test_actx_compile_python_scalar(actx_factory): + from arraycontext import (to_numpy, from_numpy) + actx = actx_factory() + + compiled_rhs = actx.compile(scale_and_orthogonalize) + + v_x = np.random.rand(10) + v_y = np.random.rand(10) + + vel = from_numpy(Velocity2D(v_x, v_y, actx), actx) + + scaled_speed = compiled_rhs(3.14, vel) + + result = to_numpy(scaled_speed, actx) + np.testing.assert_allclose(result.u, -3.14*v_y) + np.testing.assert_allclose(result.v, 3.14*v_x) + # }}} -- GitLab