Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix rounding in slicing (David Wei Chang)
  • Loading branch information
inducer committed Jul 5, 2015
1 parent 1575813 commit b93e797
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyopencl/array.py
Expand Up @@ -1517,7 +1517,7 @@ def __getitem__(self, index):

array_stride = self.strides[array_axis]

new_shape.append((stop-start)//idx_stride)
new_shape.append((stop-start-1)//idx_stride+1)
new_strides.append(idx_stride*array_stride)
new_offset += array_stride*start

Expand Down
13 changes: 13 additions & 0 deletions test/test_array.py
Expand Up @@ -817,6 +817,19 @@ def test_reshape(ctx_factory):
a_dev.reshape(-1, -1, 4)


def test_skip_slicing(ctx_factory):
context = ctx_factory()
queue = cl.CommandQueue(context)

a_host = np.arange(16).reshape((4, 4))
b_host = a_host[::3]

a = cl_array.to_device(queue, a_host)
b = a[::3]
assert b.shape == b_host.shape
assert np.array_equal(b[1].get(), b_host[1])


if __name__ == "__main__":
# make sure that import failures get reported, instead of skipping the
# tests.
Expand Down

0 comments on commit b93e797

Please sign in to comment.