Commit de4350ba authored by Theo Steininger's avatar 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
......@@ -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.
......@@ -24,9 +24,34 @@ import numpy as np
from d2o import distributed_data_object
from numpy.testing import assert_, assert_equal, assert_almost_equal,\
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),
#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])
# [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):
def test_pipundexInversion(self, harmonic_partner, distribution_strategy,
binbounds, nbin,logarithmic):
p = PowerSpace(harmonic_partner=harmonic_partner,
logarithmic=logarithmic, nbin=nbin,
err_msg='pundex is not right-inverse of pindex!')
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):
def test_constructor(self, harmonic_partner, distribution_strategy,
logarithmic, nbin, binbounds, expected):
if 'error' in expected:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment