Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Simon Perkins
ducc
Commits
3538f0ce
Commit
3538f0ce
authored
Feb 25, 2020
by
Martin Reinecke
Browse files
tweak tests
parent
9a5aa7da
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
3538f0ce
...
...
@@ -23,6 +23,13 @@ test_pypocketfft_gcc:
-
python3 setup.py install --user -f
-
pytest-3 -q test
test_pypocketfft_clang
:
stage
:
testing
script
:
-
cd pypocketfft
-
CC=clang python3 setup.py install --user -f
-
pytest-3 -q test
test_pysharp_gcc
:
stage
:
testing
script
:
...
...
Dockerfile
View file @
3538f0ce
FROM
debian:testing-slim
RUN
apt-get update
&&
apt-get
install
-y
git python3-pip python3-pytest python3-pybind11 pybind11-dev
python3-pyfftw
&&
rm
-rf
/var/lib/apt/lists/
*
RUN
apt-get update
&&
apt-get
install
-y
git python3-pip python3-pytest python3-pybind11 pybind11-dev
clang++
&&
rm
-rf
/var/lib/apt/lists/
*
pypocketfft/test/test_pypocketfft.py
View file @
3538f0ce
import
pypocketfft
import
pyfftw
#
import pyfftw
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
...
...
@@ -89,53 +89,65 @@ def test1D(len, inorm, dtype):
@
pmp
(
"shp"
,
shapes
)
@
pmp
(
"nthreads"
,
(
0
,
1
,
2
))
def
test_fftn
(
shp
,
nthreads
):
@
pmp
(
"inorm"
,
[
0
,
1
,
2
])
def
test_fftn
(
shp
,
nthreads
,
inorm
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
+
1j
*
np
.
random
.
rand
(
*
shp
)
-
0.5j
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
),
fftn
(
a
,
nthreads
=
nthreads
))
<
1e-15
)
assert_
(
_l2error
(
a
,
ifftn
(
fftn
(
a
,
nthreads
=
nthreads
,
inorm
=
inorm
),
nthreads
=
nthreads
,
inorm
=
2
-
inorm
))
<
1e-15
)
a
=
a
.
astype
(
np
.
complex64
)
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
),
fftn
(
a
,
nthreads
=
nthreads
))
<
5e-7
)
assert_
(
_l2error
(
a
,
ifftn
(
fftn
(
a
,
nthreads
=
nthreads
,
inorm
=
inorm
),
nthreads
=
nthreads
,
inorm
=
2
-
inorm
))
<
5e-7
)
@
pmp
(
"shp"
,
shapes2D
)
@
pmp
(
"axes"
,
((
0
,),
(
1
,),
(
0
,
1
),
(
1
,
0
)))
def
test_fftn2D
(
shp
,
axes
):
@
pmp
(
"inorm"
,
[
0
,
1
,
2
])
def
test_fftn2D
(
shp
,
axes
,
inorm
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
+
1j
*
np
.
random
.
rand
(
*
shp
)
-
0.5j
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_
fft
.
fftn
(
a
,
axes
=
axes
),
fftn
(
a
,
axes
=
axes
))
<
1e-15
)
assert_
(
_l2error
(
a
,
i
fft
n
(
fftn
(
a
,
axes
=
axes
,
inorm
=
inorm
),
axes
=
axes
,
inorm
=
2
-
inorm
))
<
1e-15
)
a
=
a
.
astype
(
np
.
complex64
)
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_
fft
.
fftn
(
a
,
axes
=
axes
),
fftn
(
a
,
axes
=
axes
))
<
5e-7
)
assert_
(
_l2error
(
a
,
i
fft
n
(
fftn
(
a
,
axes
=
axes
,
inorm
=
inorm
),
axes
=
axes
,
inorm
=
2
-
inorm
))
<
5e-7
)
@
pmp
(
"shp"
,
shapes
)
def
test_rfftn
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
),
rfftn
(
a
))
<
1e-15
)
tmp1
=
rfftn
(
a
)
tmp2
=
fftn
(
a
)
part
=
tuple
(
slice
(
0
,
tmp1
.
shape
[
i
])
for
i
in
range
(
tmp1
.
ndim
))
assert_
(
_l2error
(
tmp1
,
tmp2
[
part
])
<
1e-15
)
a
=
a
.
astype
(
np
.
float32
)
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
),
rfftn
(
a
))
<
5e-7
)
tmp1
=
rfftn
(
a
)
tmp2
=
fftn
(
a
)
part
=
tuple
(
slice
(
0
,
tmp1
.
shape
[
i
])
for
i
in
range
(
tmp1
.
ndim
))
assert_
(
_l2error
(
tmp1
,
tmp2
[
part
])
<
5e-7
)
@
pmp
(
"shp"
,
shapes
)
def
test_rfft_scipy
(
shp
):
for
i
in
range
(
len
(
shp
)):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
assert_
(
_l2error
(
pyfftw
.
interfaces
.
scipy_fftpack
.
rfft
(
a
,
axis
=
i
),
rfft_scipy
(
a
,
axis
=
i
))
<
1e-15
)
assert_
(
_l2error
(
pyfftw
.
interfaces
.
scipy_fftpack
.
irfft
(
a
,
axis
=
i
),
irfft_scipy
(
a
,
axis
=
i
,
inorm
=
2
))
<
1e-15
)
#
@pmp("shp", shapes)
#
def test_rfft_scipy(shp):
#
for i in range(len(shp)):
#
a = np.random.rand(*shp)-0.5
#
assert_(_l2error(pyfftw.interfaces.scipy_fftpack.rfft(a, axis=i),
#
rfft_scipy(a, axis=i)) < 1e-15)
#
assert_(_l2error(pyfftw.interfaces.scipy_fftpack.irfft(a, axis=i),
#
irfft_scipy(a, axis=i, inorm=2)) < 1e-15)
@
pmp
(
"shp"
,
shapes2D
)
@
pmp
(
"axes"
,
((
0
,),
(
1
,),
(
0
,
1
),
(
1
,
0
)))
def
test_rfftn2D
(
shp
,
axes
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
,
axes
=
axes
),
rfftn
(
a
,
axes
=
axes
))
<
1e-15
)
tmp1
=
rfftn
(
a
,
axes
=
axes
)
tmp2
=
fftn
(
a
,
axes
=
axes
)
part
=
tuple
(
slice
(
0
,
tmp1
.
shape
[
i
])
for
i
in
range
(
tmp1
.
ndim
))
assert_
(
_l2error
(
tmp1
,
tmp2
[
part
])
<
1e-15
)
a
=
a
.
astype
(
np
.
float32
)
assert_
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
,
axes
=
axes
),
rfftn
(
a
,
axes
=
axes
))
<
5e-7
)
tmp1
=
rfftn
(
a
,
axes
=
axes
)
tmp2
=
fftn
(
a
,
axes
=
axes
)
part
=
tuple
(
slice
(
0
,
tmp1
.
shape
[
i
])
for
i
in
range
(
tmp1
.
ndim
))
assert_
(
_l2error
(
tmp1
,
tmp2
[
part
])
<
5e-7
)
@
pmp
(
"shp"
,
shapes
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment