Commit 383d0a19 authored by Jait Dixit's avatar Jait Dixit
Browse files

Refactor tests

- Move custom_name_func to common
- Add tests for basic Space interface
parent 55c0ffa4
Pipeline #9580 failed with stage
in 29 minutes and 15 seconds
from nose_parameterized import parameterized
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)),
)
expand = lambda z: parameterized.expand(z,
testcase_func_name=custom_name_func)
# -*- coding: utf-8 -*-
from nose_parameterized import parameterized
import unittest
import numpy as np
......@@ -16,15 +15,8 @@ from nifty import Field,\
from d2o import distributed_data_object,\
STRATEGIES
from test.common import expand
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)),
)
expand = lambda z: parameterized.expand(z,
testcase_func_name=custom_name_func)
np.random.seed(123)
SPACES = [RGSpace((4,), dtype=np.float), RGSpace((5), dtype=np.complex)]
......@@ -55,4 +47,4 @@ class Test_Interface(unittest.TestCase):
# itertools.product(SPACE_COMBINATIONS,
# []
# )
# def test_
\ No newline at end of file
# def test_
import unittest
import numpy as np
from itertools import product
from numpy.testing import assert_
from nifty import RGSpace, LMSpace, GLSpace, HPSpace
from test.common import expand
SPACES = [RGSpace((4,)), LMSpace(5), GLSpace(4), HPSpace(4)]
class SpaceInterfaceTestCase(unittest.TestCase):
@expand(product(SPACES, [['dtype', np.dtype],
['harmonic', bool],
['shape', tuple],
['dim', int],
['total_volume', np.float]]))
def test_return_types(self, space, attr_expected_type):
assert_(isinstance(getattr(
space, attr_expected_type[0]), attr_expected_type[1]))
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