Skip to content

Commit

Permalink
Better checking for stride equality
Browse files Browse the repository at this point in the history
Ignore dimensions where the shape is 1, since the stride in these
dimensions does not matter. This is necessary when the Numpy flag
``NPY_RELAXED_STRIDES_CHECKING`` is set.
  • Loading branch information
hunse committed Sep 12, 2016
1 parent 64702c9 commit be22d0c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pyopencl/array.py
Expand Up @@ -38,6 +38,7 @@
as_strided as _as_strided,
f_contiguous_strides as _f_contiguous_strides,
c_contiguous_strides as _c_contiguous_strides,
equal_strides as _equal_strides,
ArrayFlags as _ArrayFlags,
get_common_dtype as _get_common_dtype_base)
from pyopencl.characterize import has_double_support
Expand Down Expand Up @@ -649,9 +650,7 @@ def set(self, ary, queue=None, async=False):
if not ary.flags.forc:
raise RuntimeError("cannot set from non-contiguous array")

ary = ary.copy()

if ary.strides != self.strides:
if not _equal_strides(ary.strides, self.strides, self.shape):
from warnings import warn
warn("Setting array from one with different "
"strides/storage order. This will cease to work "
Expand Down

0 comments on commit be22d0c

Please sign in to comment.