Commit dba4b443 authored by Theo Steininger's avatar Theo Steininger

Fixed RGSpace Tests

parent fd98cba2
Pipeline #16546 canceled with stage
in 18 minutes and 34 seconds
......@@ -23,8 +23,9 @@ import numpy as np
from d2o import distributed_data_object
from numpy.testing import assert_, assert_equal, assert_almost_equal
from nifty import RGSpace
from numpy.testing import assert_, assert_equal, assert_almost_equal, \
assert_array_equal
from nifty import RGSpace, nifty_configuration
from test.common import expand
from itertools import product
......@@ -66,23 +67,23 @@ CONSTRUCTOR_CONFIGS = [
'dim': 8,
'total_volume': 96.0
}],
[(11, 11), (False, True), None, False,
[(11, 11), False, None, False,
{
'shape': (11, 11),
'zerocenter': (False, True),
'zerocenter': (False, False),
'distances': (1/11, 1/11),
'harmonic': False,
'dim': 121,
'total_volume': 1.0
}],
[(11, 11), True, (1.3, 1.3), True,
[(12, 12), True, (1.3, 1.3), True,
{
'shape': (11, 11),
'shape': (12, 12),
'zerocenter': (True, True),
'distances': (1.3, 1.3),
'harmonic': True,
'dim': 121,
'total_volume': 204.49
'dim': 144,
'total_volume': 243.36
}]
]
......@@ -156,13 +157,17 @@ class RGSpaceFunctionalityTests(unittest.TestCase):
@expand(product([(10,), (11,), (1, 1), (4, 4), (5, 7), (8, 12), (7, 16),
(4, 6, 8), (17, 5, 3)],
[True, False]))
def test_hermitianize_inverter(self, shape, zerocenter):
[True, False],
['real', 'complex']))
def test_hermitianize_inverter(self, shape, zerocenter, base):
r = RGSpace(shape, harmonic=True, zerocenter=zerocenter)
v = distributed_data_object(global_shape=shape, dtype=np.complex128)
v[:] = np.random.random(shape) + 1j*np.random.random(shape)
nifty_configuration['harmonic_rg_base'] = base
inverted = r.hermitianize_inverter(v, axes=range(len(shape)))
if base == 'complex':
# test hermitian flipping of `inverted`
it = np.nditer(v, flags=['multi_index'])
while not it.finished:
......@@ -176,6 +181,8 @@ class RGSpaceFunctionalityTests(unittest.TestCase):
i2 = tuple(i2)
assert_almost_equal(inverted[i1], v[i2])
it.iternext()
else:
assert_array_equal(v, inverted)
@expand(get_distance_array_configs())
def test_distance_array(self, shape, distances, zerocenter, expected):
......
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