Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
de4350ba
Commit
de4350ba
authored
May 12, 2017
by
Theo Steininger
Browse files
Merge branch 'test_PowerSpace' into 'master'
Test power space See merge request
!102
parents
a2118d85
65a2dcfd
Pipeline
#12361
passed with stage
in 8 minutes and 34 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
nifty/spaces/power_space/power_space.py
View file @
de4350ba
...
...
@@ -72,7 +72,9 @@ class PowerSpace(Space):
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
config : {logarithmic, nbin, binbounds}
Dictionary storing the values for `logarithmic`, `nbin`, and
`binbounds` that were used during initialization.
Notes
-----
...
...
test/test_spaces/test_power_space.py
View file @
de4350ba
...
...
@@ -24,9 +24,34 @@ import numpy as np
from
d2o
import
distributed_data_object
from
numpy.testing
import
assert_
,
assert_equal
,
assert_almost_equal
,
\
assert_raises
from
nifty
import
PowerSpace
,
RGSpace
,
Space
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
from
d2o.config
import
dependency_injector
as
gdi
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
(
'pyfftw'
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
)
# [harmonic_partner, distribution_strategy,
# logarithmic, nbin, binbounds, expected]
...
...
@@ -103,9 +128,25 @@ 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
):
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!'
)
@
expand
(
CONSISTENCY_CONFIGS
)
def
test_rhopindexConsistency
(
self
,
harmonic_partner
,
distribution_strategy
,
binbounds
,
nbin
,
logarithmic
):
assert_equal
(
p
.
pindex
.
flatten
().
bincount
(),
p
.
rho
,
err_msg
=
'rho is not equal to pindex degeneracy'
)
class
PowerSpaceFunctionalityTest
(
unittest
.
TestCase
):
@
expand
(
CONS
TRUCTOR
_CONFIGS
)
@
expand
(
CONS
ISTENCY
_CONFIGS
)
def
test_constructor
(
self
,
harmonic_partner
,
distribution_strategy
,
logarithmic
,
nbin
,
binbounds
,
expected
):
if
'error'
in
expected
:
...
...
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