From 577754525ad8b50511c6979f0a860b6070c49273 Mon Sep 17 00:00:00 2001
From: Theo Steininger <theo.steininger@ultimanet.de>
Date: Thu, 13 Jul 2017 02:19:36 +0200
Subject: [PATCH] Improved tests.

---
 test/test_spaces/test_lm_space.py | 15 ++++++---------
 test/test_spaces/test_rg_space.py |  7 ++++---
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/test/test_spaces/test_lm_space.py b/test/test_spaces/test_lm_space.py
index 8442a9647..0d84a52fc 100644
--- a/test/test_spaces/test_lm_space.py
+++ b/test/test_spaces/test_lm_space.py
@@ -20,7 +20,7 @@ import unittest
 import numpy as np
 
 from numpy.testing import assert_, assert_equal, assert_raises,\
-        assert_almost_equal
+        assert_almost_equal, assert_array_almost_equal
 from d2o import distributed_data_object
 from nifty import LMSpace
 from test.common import expand
@@ -108,15 +108,12 @@ class LMSpaceFunctionalityTests(unittest.TestCase):
             for key, value in expected.iteritems():
                 assert_equal(getattr(l, key), value)
 
-    @expand(get_hermitian_configs())
-    def test_hermitian_decomposition(self, x, real, imag):
+    def test_hermitianize_inverter(self):
         l = LMSpace(5)
-        assert_almost_equal(
-            l.hermitian_decomposition(distributed_data_object(x))[0],
-            real)
-        assert_almost_equal(
-            l.hermitian_decomposition(distributed_data_object(x))[1],
-            imag*1j)
+        v = distributed_data_object(global_shape=l.shape, dtype=np.complex128)
+        v[:] = np.random.random(l.shape) + 1j*np.random.random(l.shape)
+        inverted = l.hermitianize_inverter(v, axes=(0,))
+        assert_array_almost_equal(inverted.get_full_data(), v.get_full_data())
 
     @expand(get_weight_configs())
     def test_weight(self, x, power, axes, inplace, expected):
diff --git a/test/test_spaces/test_rg_space.py b/test/test_spaces/test_rg_space.py
index 2b3e348e9..901afa27c 100644
--- a/test/test_spaces/test_rg_space.py
+++ b/test/test_spaces/test_rg_space.py
@@ -21,6 +21,8 @@ from __future__ import division
 import unittest
 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 test.common import expand
@@ -157,9 +159,8 @@ class RGSpaceFunctionalityTests(unittest.TestCase):
                     [True, False]))
     def test_hermitianize_inverter(self, shape, zerocenter):
         r = RGSpace(shape, harmonic=True, zerocenter=zerocenter)
-        v = np.empty(shape, dtype=np.complex128)
-        v.real = np.random.random(shape)
-        v.imag = np.random.random(shape)
+        v = distributed_data_object(global_shape=shape, dtype=np.complex128)
+        v[:] = np.random.random(shape) + 1j*np.random.random(shape)
         inverted = r.hermitianize_inverter(v, axes=range(len(shape)))
 
         # test hermitian flipping of `inverted`
-- 
GitLab