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
ift
NIFTy
Commits
23c5f455
Commit
23c5f455
authored
Jun 01, 2017
by
Martin Reinecke
Browse files
PEP8 and test tweaking
parent
339398ad
Pipeline
#13205
passed with stage
in 5 minutes and 15 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/config/nifty_config.py
View file @
23c5f455
...
...
@@ -31,8 +31,9 @@ dependency_injector = keepers.DependencyInjector(
'pyHealpix'
,
'plotly'
])
dependency_injector
.
register
((
'pyfftw'
,
'fftw_mpi'
),
lambda
z
:
hasattr
(
z
,
'FFTW_MPI'
))
dependency_injector
.
register
((
'pyfftw'
,
'fftw_scalar'
))
dependency_injector
.
register
((
'pyfftw'
,
'fftw_mpi'
),
lambda
z
:
hasattr
(
z
,
'FFTW_MPI'
))
dependency_injector
.
register
((
'pyfftw'
,
'fftw_scalar'
))
# Initialize the variables
variable_fft_module
=
keepers
.
Variable
(
...
...
nifty/operators/fft_operator/transformations/rg_transforms.py
View file @
23c5f455
...
...
@@ -634,9 +634,11 @@ class ScalarFFT(Transform):
# perform the transformation
if
fftw_scalar
is
not
None
:
if
self
.
codomain
.
harmonic
:
result_val
=
fftw_scalar
.
interfaces
.
numpy_fft
.
fftn
(
local_val
,
axes
=
axes
)
result_val
=
fftw_scalar
.
interfaces
.
numpy_fft
.
fftn
(
local_val
,
axes
=
axes
)
else
:
result_val
=
fftw_scalar
.
interfaces
.
numpy_fft
.
ifftn
(
local_val
,
axes
=
axes
)
result_val
=
fftw_scalar
.
interfaces
.
numpy_fft
.
ifftn
(
local_val
,
axes
=
axes
)
else
:
if
self
.
codomain
.
harmonic
:
result_val
=
np
.
fft
.
fftn
(
local_val
,
axes
=
axes
)
...
...
test/test_operators/test_fft_operator.py
View file @
23c5f455
...
...
@@ -62,7 +62,7 @@ class FFTOperatorTests(unittest.TestCase):
res
=
foo
.
get_distance_array
(
'not'
)
assert_equal
(
res
[
zc1
*
(
dim1
//
2
),
zc2
*
(
dim2
//
2
)],
0.
)
@
expand
(
product
([
"scalar"
,
"mpi"
],
[
10
,
11
],
[
False
,
True
],
[
False
,
True
],
@
expand
(
product
([
"scalar"
,
"mpi"
],
[
10
,
11
],
[
False
,
True
],
[
False
,
True
],
[
0.1
,
1
,
3.7
],
[
np
.
float64
,
np
.
complex128
,
np
.
float32
,
np
.
complex64
]))
def
test_fft1D
(
self
,
module
,
dim1
,
zc1
,
zc2
,
d
,
itp
):
...
...
test/test_spaces/test_power_space.py
View file @
23c5f455
...
...
@@ -28,30 +28,34 @@ from nifty import PowerSpace, RGSpace, Space, LMSpace
from
types
import
NoneType
from
test.common
import
expand
from
itertools
import
product
,
chain
#needed to check wether fftw is available
#
needed to check wether fftw is available
from
d2o.config
import
dependency_injector
as
gdi
from
nose.plugins.skip
import
SkipTest
HARMONIC_SPACES
=
[
RGSpace
((
8
,),
harmonic
=
True
),
RGSpace
((
7
,),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
8
,),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
7
,
8
),
harmonic
=
True
),
RGSpace
((
7
,
8
),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
6
,
6
),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
7
,
5
),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
5
,
5
),
harmonic
=
True
),
RGSpace
((
4
,
5
,
7
),
harmonic
=
True
),
RGSpace
((
4
,
5
,
7
),
harmonic
=
True
,
zerocenter
=
True
),
LMSpace
(
6
),
LMSpace
(
9
)]
#Try all sensible kinds of combinations of spaces, distributuion strategy and
#binning parameters
_maybe_fftw
=
[
"fftw"
]
if
(
'fftw_mpi'
in
gdi
)
else
[]
CONSISTENCY_CONFIGS_IMPLICIT
=
product
(
HARMONIC_SPACES
,
[
"not"
,
"equal"
]
+
_maybe_fftw
,
[
None
],
[
None
,
3
,
4
],
[
True
,
False
])
CONSISTENCY_CONFIGS_EXPLICIT
=
product
(
HARMONIC_SPACES
,
[
"not"
,
"equal"
]
+
_maybe_fftw
,
[[
0.
,
1.3
]],[
None
],[
False
])
CONSISTENCY_CONFIGS
=
chain
(
CONSISTENCY_CONFIGS_IMPLICIT
,
CONSISTENCY_CONFIGS_EXPLICIT
)
RGSpace
((
7
,),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
8
,),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
7
,
8
),
harmonic
=
True
),
RGSpace
((
7
,
8
),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
6
,
6
),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
7
,
5
),
harmonic
=
True
,
zerocenter
=
True
),
RGSpace
((
5
,
5
),
harmonic
=
True
),
RGSpace
((
4
,
5
,
7
),
harmonic
=
True
),
RGSpace
((
4
,
5
,
7
),
harmonic
=
True
,
zerocenter
=
True
),
LMSpace
(
6
),
LMSpace
(
9
)]
# Try all sensible kinds of combinations of spaces, distributuion strategy and
# binning parameters
CONSISTENCY_CONFIGS_IMPLICIT
=
product
(
HARMONIC_SPACES
,
[
"not"
,
"equal"
,
"fftw"
],
[
None
],
[
None
,
3
,
4
],
[
True
,
False
])
CONSISTENCY_CONFIGS_EXPLICIT
=
product
(
HARMONIC_SPACES
,
[
"not"
,
"equal"
,
"fftw"
],
[[
0.
,
1.3
]],
[
None
],
[
False
])
CONSISTENCY_CONFIGS
=
chain
(
CONSISTENCY_CONFIGS_IMPLICIT
,
CONSISTENCY_CONFIGS_EXPLICIT
)
# [harmonic_partner, distribution_strategy,
# logarithmic, nbin, binbounds, expected]
...
...
@@ -128,27 +132,40 @@ class PowerSpaceInterfaceTest(unittest.TestCase):
p
=
PowerSpace
(
r
)
assert_
(
isinstance
(
getattr
(
p
,
attribute
),
expected_type
))
class
PowerSpaceConsistencyCheck
(
unittest
.
TestCase
):
@
expand
(
CONSISTENCY_CONFIGS
)
def
test_pipundexInversion
(
self
,
harmonic_partner
,
distribution_strategy
,
binbounds
,
nbin
,
logarithmic
):
binbounds
,
nbin
,
logarithmic
):
if
distribution_strategy
==
"fftw"
and
"fftw_mpi"
not
in
gdi
:
raise
SkipTest
p
=
PowerSpace
(
harmonic_partner
=
harmonic_partner
,
distribution_strategy
=
distribution_strategy
,
logarithmic
=
logarithmic
,
nbin
=
nbin
,
binbounds
=
binbounds
)
assert_equal
(
p
.
pindex
.
flatten
()[
p
.
pundex
],
np
.
arange
(
p
.
dim
),
err_msg
=
'pundex is not right-inverse of pindex!'
)
distribution_strategy
=
distribution_strategy
,
logarithmic
=
logarithmic
,
nbin
=
nbin
,
binbounds
=
binbounds
)
assert_equal
(
p
.
pindex
.
flatten
()[
p
.
pundex
],
np
.
arange
(
p
.
dim
),
err_msg
=
'pundex is not right-inverse of pindex!'
)
@
expand
(
CONSISTENCY_CONFIGS
)
def
test_rhopindexConsistency
(
self
,
harmonic_partner
,
distribution_strategy
,
binbounds
,
nbin
,
logarithmic
):
def
test_rhopindexConsistency
(
self
,
harmonic_partner
,
distribution_strategy
,
binbounds
,
nbin
,
logarithmic
):
if
distribution_strategy
==
"fftw"
and
"fftw_mpi"
not
in
gdi
:
raise
SkipTest
p
=
PowerSpace
(
harmonic_partner
=
harmonic_partner
,
distribution_strategy
=
distribution_strategy
,
logarithmic
=
logarithmic
,
nbin
=
nbin
,
binbounds
=
binbounds
)
assert_equal
(
p
.
pindex
.
flatten
().
bincount
(),
p
.
rho
,
err_msg
=
'rho is not equal to pindex degeneracy'
)
err_msg
=
'rho is not equal to pindex degeneracy'
)
class
PowerSpaceFunctionalityTest
(
unittest
.
TestCase
):
@
expand
(
CONS
ISTENCY
_CONFIGS
)
@
expand
(
CONS
TRUCTOR
_CONFIGS
)
def
test_constructor
(
self
,
harmonic_partner
,
distribution_strategy
,
logarithmic
,
nbin
,
binbounds
,
expected
):
if
distribution_strategy
==
"fftw"
and
"fftw_mpi"
not
in
gdi
:
raise
SkipTest
if
'error'
in
expected
:
with
assert_raises
(
expected
[
'error'
]):
PowerSpace
(
harmonic_partner
=
harmonic_partner
,
...
...
Write
Preview
Supports
Markdown
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