Commit 8ecae7a7 authored by Theo Steininger's avatar Theo Steininger
Browse files

Updated tests.

parent aa122818
Pipeline #11624 passed with stage
in 10 minutes and 7 seconds
......@@ -67,11 +67,12 @@ def expand(*args, **kwargs):
def generate_spaces():
spaces = [RGSpace(4), PowerSpace(RGSpace((4, 4), harmonic=True)),
LMSpace(5), HPSpace(4), GLSpace(4)]
LMSpace(5), HPSpace(4)]
if 'pyHealpix' in di:
spaces.append(GLSpace(4))
return spaces
def generate_harmonic_spaces():
spaces = [RGSpace(4),LMSpace(5)]
def generate_harmonic_spaces():
spaces = [RGSpace(4, harmonic=True), LMSpace(5)]
return spaces
......@@ -46,7 +46,7 @@ CONSTRUCTOR_CONFIGS = [
def get_weight_configs():
np.random.seed(42)
wgt=[ 2.0943951, 2.0943951]
wgt = [2.0943951, 2.0943951]
# for GLSpace(nlat=2, nlon=3)
weight_0 = np.array(list(itertools.chain.from_iterable(
itertools.repeat(x, 3) for x in wgt)))
......@@ -69,13 +69,22 @@ class GLSpaceInterfaceTests(unittest.TestCase):
@expand([['nlat', int],
['nlon', int]])
def test_property_ret_type(self, attribute, expected_type):
g = GLSpace(2)
assert_(isinstance(getattr(g, attribute), expected_type))
try:
g = GLSpace(2)
except ImportError:
raise SkipTest
else:
assert_(isinstance(getattr(g, attribute), expected_type))
class GLSpaceFunctionalityTests(unittest.TestCase):
@expand(CONSTRUCTOR_CONFIGS)
def test_constructor(self, nlat, nlon, dtype, expected):
try:
g = GLSpace(4)
except ImportError:
raise SkipTest
if 'error' in expected:
with assert_raises(expected['error']):
GLSpace(nlat, nlon, dtype)
......@@ -86,6 +95,11 @@ class GLSpaceFunctionalityTests(unittest.TestCase):
@expand(get_weight_configs())
def test_weight(self, x, power, axes, inplace, expected):
try:
g = GLSpace(4)
except ImportError:
raise SkipTest
if 'pyHealpix' not in di:
raise SkipTest
else:
......
......@@ -22,7 +22,6 @@ import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises,\
assert_almost_equal
from nifty import HPSpace
from nifty.config import dependency_injector as di
from test.common import expand
# [nside, dtype, expected]
......
......@@ -50,6 +50,7 @@ CONSTRUCTOR_CONFIGS = [
}]
]
def _distance_array_helper(index_arr, lmax):
if index_arr <= lmax:
index_half = index_arr
......@@ -64,6 +65,7 @@ def _distance_array_helper(index_arr, lmax):
return index_half - m*(2*lmax + 1 - m)//2
def get_distance_array_configs():
da_0 = [_distance_array_helper(idx, 5) for idx in np.arange(36)]
return [[5, None, da_0]]
......@@ -77,6 +79,7 @@ def get_weight_configs():
[w_0_x.copy(), 1, None, True, w_0_x]
]
def get_hermitian_configs():
np.random.seed(42)
h_0_res_real = np.random.rand(32, 16, 6).astype(np.complex128)
......@@ -86,6 +89,7 @@ def get_hermitian_configs():
[h_0_x, h_0_res_real, h_0_res_imag]
]
class LMSpaceInterfaceTests(unittest.TestCase):
@expand([['lmax', int],
['mmax', int],
......
......@@ -24,7 +24,7 @@ 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, LMSpace, Space
from nifty import PowerSpace, RGSpace, Space
from types import NoneType
from test.common import expand
......
......@@ -218,7 +218,6 @@ def get_hermitian_configs():
]
class RGSpaceInterfaceTests(unittest.TestCase):
@expand([['distances', tuple],
['zerocenter', tuple]])
......
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