diff --git a/meshmode/array_context.py b/meshmode/array_context.py index 81461b71aa9008e52fcb379532cfc51ea5de4b2c..88d3ecf412f033833272d696de2e70c9b35266f6 100644 --- a/meshmode/array_context.py +++ b/meshmode/array_context.py @@ -224,6 +224,11 @@ class _PyOpenCLFakeNumpyNamespace(_BaseFakeNumpyNamespace): return super().__getattr__(name) + @obj_array_vectorized_n_args + def where(self, criterion, then, else_): + import pyopencl.array as cl_array + return cl_array.if_positive(criterion != 0, then, else_) + class PyOpenCLArrayContext(ArrayContext): """ diff --git a/requirements.txt b/requirements.txt index 97a59e396188c073a0942955f361fc43c8d51f23..4c3ff3392cea23471a0778e46ae7625bd6b7094e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ numpy -git+https://gitlab.tiker.net/inducer/pytools.git -git+https://gitlab.tiker.net/inducer/gmsh_interop.git -git+https://gitlab.tiker.net/inducer/modepy.git -git+https://gitlab.tiker.net/inducer/pyopencl.git -git+https://gitlab.tiker.net/inducer/islpy.git +git+https://gitlab.tiker.net/inducer/pytools.git#egg=pytools +git+https://gitlab.tiker.net/inducer/gmsh_interop.git#egg=gmsh_interop +git+https://gitlab.tiker.net/inducer/modepy.git#egg=modepy +git+https://gitlab.tiker.net/inducer/pyopencl.git#egg=pyopencl +git+https://gitlab.tiker.net/inducer/islpy.git#egg=islpy # required by pytential, which is in turn needed for some tests -git+https://gitlab.tiker.net/inducer/pymbolic.git +git+https://gitlab.tiker.net/inducer/pymbolic.git#egg=pymbolic # also depends on pymbolic, so should come after it -git+https://gitlab.tiker.net/inducer/loopy.git +git+https://gitlab.tiker.net/inducer/loopy.git#egg=loo.py # more pytential dependencies -git+https://github.com/inducer/boxtree.git -git+https://github.com/inducer/sumpy.git -git+https://github.com/inducer/pytential.git +git+https://github.com/inducer/boxtree.git#egg=boxtree +git+https://github.com/inducer/sumpy.git#egg=sumpy +git+https://github.com/inducer/pytential.git#pytential # requires pymetis for tests for partition_mesh -git+https://gitlab.tiker.net/inducer/pymetis.git +git+https://gitlab.tiker.net/inducer/pymetis.git#egg=pymetis diff --git a/test/test_meshmode.py b/test/test_meshmode.py index e6312f55cc7a8e88c62988ebb98f28edab5fb98e..17773c2086e0419705fac109175d77ebb34c0220 100644 --- a/test/test_meshmode.py +++ b/test/test_meshmode.py @@ -1467,6 +1467,7 @@ def test_array_context_np_workalike(ctx_factory): ("arctan2", 2), ("minimum", 2), ("maximum", 2), + ("where", 3), ]: args = [np.random.randn(discr.ndofs) for i in range(n_args)] ref_result = getattr(np, sym_name)(*args)