Commit 95313ffe authored by Martin Reinecke's avatar Martin Reinecke
Browse files

small test cleanups

parent 1cf013f7
......@@ -18,13 +18,12 @@
from builtins import str
from parameterized import parameterized
import nifty4 as ift
import numpy as np
np.seterr(all='raise', under='ignore')
def custom_name_func(testcase_func, param_num, param):
def _custom_name_func(testcase_func, param_num, param):
return "%s_%s" % (
testcase_func.__name__,
parameterized.to_safe_name("_".join(str(x) for x in param.args)),
......@@ -32,17 +31,5 @@ def custom_name_func(testcase_func, param_num, param):
def expand(*args, **kwargs):
return parameterized.expand(*args, testcase_func_name=custom_name_func,
return parameterized.expand(*args, testcase_func_name=_custom_name_func,
**kwargs)
def generate_spaces():
spaces = [ift.RGSpace(4),
ift.PowerSpace(ift.RGSpace((4, 4), harmonic=True)),
ift.LMSpace(5), ift.HPSpace(4), ift.GLSpace(4)]
return spaces
def generate_harmonic_spaces():
spaces = [ift.RGSpace(4, harmonic=True), ift.LMSpace(5)]
return spaces
......@@ -19,13 +19,14 @@
import unittest
from numpy.testing import assert_allclose, assert_equal
import nifty4 as ift
from test.common import generate_spaces
from itertools import product
from test.common import expand
class ComposedOperator_Tests(unittest.TestCase):
spaces = generate_spaces()
spaces = [ift.RGSpace(4),
ift.PowerSpace(ift.RGSpace((4, 4), harmonic=True)),
ift.LMSpace(5), ift.HPSpace(4), ift.GLSpace(4)]
@expand(product(spaces, spaces))
def test_times_adjoint_times(self, space1, space2):
......
......@@ -20,13 +20,14 @@ from __future__ import division
import unittest
from numpy.testing import assert_equal, assert_allclose
import nifty4 as ift
from test.common import generate_spaces
from itertools import product
from test.common import expand
class DiagonalOperator_Tests(unittest.TestCase):
spaces = generate_spaces()
spaces = [ift.RGSpace(4),
ift.PowerSpace(ift.RGSpace((4, 4), harmonic=True)),
ift.LMSpace(5), ift.HPSpace(4), ift.GLSpace(4)]
@expand(product(spaces))
def test_property(self, space):
......
......@@ -20,12 +20,16 @@ import unittest
from numpy.testing import assert_
from itertools import product
from types import LambdaType
from test.common import expand, generate_spaces, generate_harmonic_spaces
from test.common import expand
import nifty4 as ift
spaces = [ift.RGSpace(4),
ift.PowerSpace(ift.RGSpace((4, 4), harmonic=True)),
ift.LMSpace(5), ift.HPSpace(4), ift.GLSpace(4)]
class SpaceInterfaceTests(unittest.TestCase):
@expand(product(generate_spaces(), [
@expand(product(spaces, [
['harmonic', bool],
['shape', tuple],
['size', int]]))
......@@ -33,7 +37,7 @@ class SpaceInterfaceTests(unittest.TestCase):
assert_(isinstance(getattr(space, attr_expected_type[0]),
attr_expected_type[1]))
@expand(product(generate_harmonic_spaces(), [
@expand(product([ift.RGSpace(4, harmonic=True), ift.LMSpace(5)], [
['get_k_length_array', ift.Field],
['get_fft_smoothing_kernel_function', 2.0, LambdaType],
]))
......
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