Commit f3a3a97a authored by Martin Reinecke's avatar Martin Reinecke

more tests

parent 17013e3d
Pipeline #23533 passed with stage
in 4 minutes and 34 seconds
from nifty2go import *
# This tests if it is possible to import all of Nifty's methods.
# Experience shows this is not always possible.
pass
......@@ -61,3 +61,13 @@ class ComposedOperator_Tests(unittest.TestCase):
res = full_op(x)
assert_equal(isinstance(full_op, ift.DiagonalOperator), True)
assert_allclose(ift.dobj.to_global_data(res.val), 432.)
@expand(product(spaces))
def test_mix(self, space):
op1 = ift.DiagonalOperator(ift.Field(space, 2.))
op2 = ift.ScalingOperator(3., space)
full_op = op1 * (op2 + op2) * op1 * op1 - op1 * op2
x = ift.Field(space, 1.)
res = full_op(x)
assert_equal(isinstance(full_op, ift.DiagonalOperator), True)
assert_allclose(ift.dobj.to_global_data(res.val), 42.)
......@@ -21,7 +21,7 @@ from numpy.testing import assert_
from itertools import product
from types import LambdaType
from test.common import expand, generate_spaces, generate_harmonic_spaces
from nifty2go import * # ugly, but needed for the eval() below
import nifty2go as ift
class SpaceInterfaceTests(unittest.TestCase):
......@@ -34,14 +34,10 @@ class SpaceInterfaceTests(unittest.TestCase):
attr_expected_type[1]))
@expand(product(generate_harmonic_spaces(), [
['get_k_length_array', Field],
['get_k_length_array', ift.Field],
['get_fft_smoothing_kernel_function', 2.0, LambdaType],
]))
def test_method_ret_type(self, space, method_expected_type):
assert_(type(getattr(space, method_expected_type[0])(
*method_expected_type[1:-1])) is
method_expected_type[-1])
@expand([[space] for space in generate_spaces()])
def test_repr(self, space):
assert_(space == eval(space.__repr__()))
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