test_field.py 2.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# NIFTy
# Copyright (C) 2017  Theo Steininger
#
# Author: Theo Steininger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
20
21
22
23
24

import unittest

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

25
from itertools import product
26
27
28
29
30
31
32
33

from nifty import Field,\
                  RGSpace,\
                  FieldArray

from d2o import distributed_data_object,\
                STRATEGIES

Jait Dixit's avatar
Jait Dixit committed
34
from test.common import expand
35
36
37

np.random.seed(123)

Martin Reinecke's avatar
Martin Reinecke committed
38
SPACES = [RGSpace((4,)), RGSpace((5))]
Theo Steininger's avatar
Theo Steininger committed
39
SPACE_COMBINATIONS = [(), SPACES[0], SPACES[1], SPACES]
40
41
42


class Test_Interface(unittest.TestCase):
43
    @expand(product(SPACE_COMBINATIONS,
Martin Reinecke's avatar
Martin Reinecke committed
44
                    [['distribution_strategy', str],
45
46
47
48
49
50
51
52
53
54
                     ['domain', tuple],
                     ['domain_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]
55
        f = Field(domain=domain)
56
57
58
59
60
61
62
63
        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
64
#    def test_