test_field.py 1.57 KB
Newer Older
1
2
3
4
5
6
7
8
# -*- coding: utf-8 -*-

import unittest

import numpy as np
from numpy.testing import assert_,\
                          assert_equal

9
from itertools import product
10
11
12
13
14
15
16
17

from nifty import Field,\
                  RGSpace,\
                  FieldArray

from d2o import distributed_data_object,\
                STRATEGIES

Jait Dixit's avatar
Jait Dixit committed
18
from test.common import expand
19
20
21
22

np.random.seed(123)

SPACES = [RGSpace((4,), dtype=np.float), RGSpace((5), dtype=np.complex)]
Theo Steininger's avatar
Theo Steininger committed
23
SPACE_COMBINATIONS = [(), SPACES[0], SPACES[1], SPACES]
24
25
26


class Test_Interface(unittest.TestCase):
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    @expand(product(SPACE_COMBINATIONS,
                    [['dtype', np.dtype],
                     ['distribution_strategy', str],
                     ['domain', tuple],
                     ['field_type', tuple],
                     ['domain_axes', tuple],
                     ['field_type_axes', tuple],
                     ['val', distributed_data_object],
                     ['shape', tuple],
                     ['dim', np.int],
                     ['dof', np.int],
                     ['total_volume', np.float]]))
    def test_return_types(self, domain, attribute_desired_type):
        attribute = attribute_desired_type[0]
        desired_type = attribute_desired_type[1]
42
        ft = FieldArray(shape=(2,), dtype=np.complex)
43
        f = Field(domain=domain, field_type=ft)
44
45
46
47
48
49
50
51
        assert_(isinstance(getattr(f, attribute), desired_type))

#class Test_Initialization(unittest.TestCase):
#
#    @parameterized.expand(
#        itertools.product(SPACE_COMBINATIONS,
#                          []
#                          )
Jait Dixit's avatar
Jait Dixit committed
52
#    def test_