From 20ff310e2a98a1c9d932bc6974d6cba621250e08 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 17 May 2021 11:03:10 -0500 Subject: [PATCH] Add test_assign_different_strides --- pyopencl/array.py | 2 +- test/test_array.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pyopencl/array.py b/pyopencl/array.py index e05ba222..03b87209 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -2019,7 +2019,7 @@ class Array: raise ValueError("cannot assign between arrays of " "differing shapes") if subarray.strides != value.strides: - raise ValueError("cannot assign between arrays of " + raise NotImplementedError("cannot assign between arrays of " "differing strides") self.add_event( diff --git a/test/test_array.py b/test/test_array.py index a63e5f3e..d8b0d7bd 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -1544,6 +1544,18 @@ def test_stack(ctx_factory, input_dims, order): np.stack((x_in, y_in), axis=axis)) +def test_assign_different_strides(ctx_factory): + cl_ctx = ctx_factory() + queue = cl.CommandQueue(cl_ctx) + + from pyopencl.clrandom import rand as clrand + + a = clrand(queue, (20, 30), dtype=np.float32) + b = cl_array.empty(queue, (20, 30), dtype=np.float32, order="F") + with pytest.raises(NotImplementedError): + b[:] = a + + if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1]) -- GitLab