diff --git a/pyopencl/array.py b/pyopencl/array.py index 88c37a2fa884c1ba8d5561c763d81cbebdfb50aa..7304081dc4ad4e2d0bba53a5f451b034e09bb50d 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -285,6 +285,10 @@ class Array(object): s = shape shape = (shape,) + if isinstance(s, np.integer): + # bombs if s is a Python integer + s = np.asscalar(s) + if strides is None: if order == "F": strides = _f_contiguous_strides( diff --git a/test/test_array.py b/test/test_array.py index 47b2f76b94f7f5fbfabadaaab37f3914f40f9acb..57ded681ce86f16554a7ca826b4d68b26b51290a 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -1113,6 +1113,14 @@ def test_sort(ctx_factory): # {{{ misc +@pytools.test.mark_test.opencl +def test_numpy_integer_shape(ctx_factory): + context = ctx_factory() + queue = cl.CommandQueue(context) + + cl_array.empty(queue, np.int32(17), np.float32) + cl_array.empty(queue, (np.int32(17), np.int32(17)), np.float32) + @pytools.test.mark_test.opencl def test_len(ctx_factory): context = ctx_factory()