Commit 0d4daa45 authored by Reimar H Leike's avatar Reimar H Leike
Browse files

added many combinations for test_PowerSpaceConsistency and added a small...

added many combinations for test_PowerSpaceConsistency and added a small clarification to PowerSpace docstring
parent 6ee5c1df
......@@ -72,7 +72,8 @@ class PowerSpace(Space):
The total volume of the space.
shape : tuple of np.ints
The shape of the space's data array.
binbounds : {array-like, None}
Inner bounds of the bins, None if they were not specified in the init.
Notes
-----
......@@ -221,6 +222,9 @@ class PowerSpace(Space):
@property
def binbounds(self):
""" Inner boundaries of the used bins if specfied during initialization.
Notes
-----
Returns None if binbounds were not specified.
"""
return self._binbounds
......
......@@ -28,6 +28,17 @@ from nifty import PowerSpace, RGSpace, Space
from types import NoneType
from test.common import expand
HARMONIC_SPACES = [RGSpace((8,), harmonic=True), RGSpace((7,8), harmonic=True), RGSpace((5,5), harmonic=True), RGSpace((4,5,7), harmonic=True),
LMSpace(6),LMSpace(9)]
BINNINGS = product([None], [None, 3,4], [True, False]) + product([0.,1.3],[None],[False])
#Try all sensible kinds of combinations of spaces, distributuion strategy and
#binning parameters
CONSISTENCY_CONFIGS = product(HARMONIC_SPACES, ["not", "equal", "fftw", "freeform"], BINNINGS)
# [harmonic_partner, distribution_strategy,
# logarithmic, nbin, binbounds, expected]
CONSTRUCTOR_CONFIGS = [
......@@ -110,25 +121,17 @@ class PowerSpaceInterfaceTest(unittest.TestCase):
assert_(isinstance(getattr(p, attribute), expected_type))
class PowerSpaceConsistencyCheck(unittest.TestCase):
@expand(CONSTRUCTOR_CONFIGS)
@expand(CONSISTENCY_CONFIGS)
def test_pipundexInversion(self, harmonic_partner, distribution_strategy,
logarithmic, nbin, binbounds, expected):
#expected will not be used TODO: write expandproduct to use for this
if 'error' in expected:
with assert_raises(expected['error']):
PowerSpace(harmonic_partner=harmonic_partner,
distribution_strategy=distribution_strategy,
logarithmic=logarithmic, nbin=nbin,
binbounds=binbounds)
else:
p = PowerSpace(harmonic_partner=harmonic_partner,
binbounds, nbin,logarithmic):
p = PowerSpace(harmonic_partner=harmonic_partner,
distribution_strategy=distribution_strategy,
logarithmic=logarithmic, nbin=nbin,
binbounds=binbounds)
assert_equal(p.pindex[p.pundex],np.arange(p.dim),err_msg='pundex is not right-inverse of pindex!')
assert_equal(p.pindex[p.pundex],np.arange(p.dim),err_msg='pundex is not right-inverse of pindex!')
class PowerSpaceFunctionalityTest(unittest.TestCase):
@expand(CONSTRUCTOR_CONFIGS)
@expand(CONSISTENCY_CONFIGS)
def test_constructor(self, harmonic_partner, distribution_strategy,
logarithmic, nbin, binbounds, expected):
if 'error' in expected:
......
Supports Markdown
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