Skip to content

Commit

Permalink
Deprecate get() between arrays of different shape
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jul 11, 2015
1 parent 955ef2f commit b67e1a4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pyopencl/array.py
Expand Up @@ -665,8 +665,12 @@ def set(self, ary, queue=None, async=False):

def get(self, queue=None, ary=None, async=False):
"""Transfer the contents of *self* into *ary* or a newly allocated
:mod:`numpy.ndarray`. If *ary* is given, it must have the right
size (not necessarily shape) and dtype.
:mod:`numpy.ndarray`. If *ary* is given, it must have the same
shape and dtype.
.. versionchanged:: 2015.2
*ary* with different shape was deprecated.
"""

if ary is None:
Expand All @@ -679,6 +683,13 @@ def get(self, queue=None, ary=None, async=False):
if ary.dtype != self.dtype:
raise TypeError("'ary' has non-matching type")

if self.shape != ary.shape:
from warnings import warn
warn("get() between arrays of different shape is deprecated "
"and will be removed in PyCUDA 2017.x",
DeprecationWarning, stacklevel=2)


assert self.flags.forc, "Array in get() must be contiguous"

if self.size:
Expand Down

0 comments on commit b67e1a4

Please sign in to comment.