Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyopencl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
pyopencl
Commits
4c20680b
Commit
4c20680b
authored
9 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Tweak array tests for current numpypy features
parent
69d4acf4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_array.py
+26
-9
26 additions, 9 deletions
test/test_array.py
with
26 additions
and
9 deletions
test/test_array.py
+
26
−
9
View file @
4c20680b
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment