From b0dfbe0d4277a12cfa564655f18f4422d297acd6 Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni Date: Sat, 26 Jun 2021 12:02:39 -0500 Subject: [PATCH] test pyopencl arithmetic --- test/test_array.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_array.py b/test/test_array.py index 9ff806e3..116863e8 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -1603,6 +1603,22 @@ def test_ravel(ctx_factory, order): x.ravel(order=order)) +def test_arithmetic_on_non_scalars(ctx_factory): + from dataclasses import dataclass + ctx = ctx_factory() + cq = cl.CommandQueue(ctx) + + @dataclass + class ArrayContainer: + _data: np.ndarray + + def __eq__(self, other): + return ArrayContainer(self._data == other) + + with pytest.raises(TypeError): + ArrayContainer(np.ones(100)) + cl.array.zeros(cq, (10,), dtype=np.float64) + + if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1]) -- GitLab