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 46b11d6 commit 8a764bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions doc/source/array.rst
Expand Up @@ -120,11 +120,15 @@ The :class:`GPUArray` Array Class
.. method :: get(ary=None, pagelocked=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. If it is not given,
:mod:`numpy.ndarray`. If *ary* is given, it must have the same
shape and dtype. If it is not given,
a *pagelocked* specifies whether the new array is allocated
page-locked.
.. versionchanged:: 2015.2
*ary* with different shape was deprecated.
.. method :: get_async(stream=None, ary=None)
Transfer the contents of *self* into *ary* or a newly allocated
Expand Down
12 changes: 12 additions & 0 deletions pycuda/gpuarray.py
Expand Up @@ -265,6 +265,12 @@ def get(self, ary=None, pagelocked=False):
assert ary.dtype == self.dtype
assert ary.flags.forc

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 All @@ -281,6 +287,12 @@ def get_async(self, stream=None, ary=None):
assert ary.dtype == self.dtype
assert ary.flags.forc

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 8a764bf

Please sign in to comment.