Skip to content
Snippets Groups Projects
Commit 4c20680b authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Tweak array tests for current numpypy features

parent 69d4acf4
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ import numpy.linalg as la
import sys
from six.moves import range
import pytest
import pyopencl as cl
import pyopencl.array as cl_array
......@@ -35,6 +36,7 @@ import pyopencl.tools as cl_tools
from pyopencl.tools import ( # noqa
pytest_generate_tests_for_pyopencl as pytest_generate_tests)
from pyopencl.characterize import has_double_support
from pyopencl.cffi_cl import _PYPY
# {{{ helpers
......@@ -471,6 +473,9 @@ def test_len(ctx_factory):
def test_stride_preservation(ctx_factory):
if _PYPY:
pytest.xfail("numpypy: no array creation from __array_interface__")
context = ctx_factory()
queue = cl.CommandQueue(context)
......@@ -564,9 +569,11 @@ def test_slice(ctx_factory):
from pyopencl.clrandom import rand as clrand
tp = np.float32
l = 20000
a_gpu = clrand(queue, (l,), dtype=np.float32)
b_gpu = clrand(queue, (l,), dtype=np.float32)
a_gpu = clrand(queue, (l,), dtype=tp)
b_gpu = clrand(queue, (l,), dtype=tp)
a = a_gpu.get()
b = b_gpu.get()
......@@ -575,8 +582,8 @@ def test_slice(ctx_factory):
start = randrange(l)
end = randrange(start, l)
a_gpu_slice = 2*a_gpu[start:end]
a_slice = 2*a[start:end]
a_gpu_slice = tp(2)*a_gpu[start:end]
a_slice = tp(2)*a[start:end]
assert la.norm(a_gpu_slice.get() - a_slice) == 0
......@@ -584,8 +591,8 @@ def test_slice(ctx_factory):
start = randrange(l)
end = randrange(start, l)
a_gpu[start:end] = 2*b[start:end]
a[start:end] = 2*b[start:end]
a_gpu[start:end] = tp(2)*b[start:end]
a[start:end] = tp(2)*b[start:end]
assert la.norm(a_gpu.get() - a) == 0
......@@ -593,8 +600,8 @@ def test_slice(ctx_factory):
start = randrange(l)
end = randrange(start, l)
a_gpu[start:end] = 2*b_gpu[start:end]
a[start:end] = 2*b[start:end]
a_gpu[start:end] = tp(2)*b_gpu[start:end]
a[start:end] = tp(2)*b[start:end]
assert la.norm(a_gpu.get() - a) == 0
......@@ -677,6 +684,9 @@ def test_any_all(ctx_factory):
def test_map_to_host(ctx_factory):
if _PYPY:
pytest.skip("numpypy: no array creation from __array_interface__")
context = ctx_factory()
queue = cl.CommandQueue(context)
......@@ -704,6 +714,10 @@ def test_map_to_host(ctx_factory):
def test_view_and_strides(ctx_factory):
if _PYPY:
pytest.xfail("numpypy: no array creation from __array_interface__")
return
context = ctx_factory()
queue = cl.CommandQueue(context)
......@@ -716,12 +730,15 @@ def test_view_and_strides(ctx_factory):
assert yv.shape == y.shape
assert yv.strides == y.strides
import pytest
with pytest.raises(AssertionError):
assert (yv.get() == x.get()[:3, :5]).all()
def test_meshmode_view(ctx_factory):
if _PYPY:
# https://bitbucket.org/pypy/numpy/issue/28/indexerror-on-ellipsis-slice
pytest.xfail("numpypy bug #28")
context = ctx_factory()
queue = cl.CommandQueue(context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment