From 27f1c331355c00ee625be531b2e6fcdb4ef5681a Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Fri, 20 Apr 2012 19:20:18 -0400 Subject: [PATCH] Minor Array improvements. --- pyopencl/array.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyopencl/array.py b/pyopencl/array.py index 8d84bb4a..bf8325c2 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -303,7 +303,9 @@ class Array(object): self.base = base - self.context = self.data.context + @property + def context(self): + return self.data.context @property @memoize_method @@ -820,12 +822,14 @@ def to_device(*args, **kwargs): """Converts a numpy array to a :class:`Array`.""" def _to_device(queue, ary, allocator=None, async=False): + if ary.dtype == object: + raise RuntimeError("to_device does not work on object arrays.") + result = Array(queue, ary.shape, ary.dtype, allocator=allocator, strides=ary.strides) result.set(ary, async=async) return result - if isinstance(args[0], cl.Context): from warnings import warn warn("Passing a context as first argument is deprecated. " -- GitLab