Commit f3e6cef2 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

rearrange tests

parent 8613ae95
Pipeline #14314 passed with stage
in 5 minutes and 10 seconds
......@@ -55,6 +55,26 @@ class Test_Interface(unittest.TestCase):
f = Field(domain=domain)
assert_(isinstance(getattr(f, attribute), desired_type))
def test_hermitian_decomposition2(self):
s1=(25,2)
s2=(16,)
ax1=((0,1,2),)
ax2=((0,1),(2,))
r2 = RGSpace(s1+s2, harmonic=True)
ra = RGSpace(s1, harmonic=True)
rb = RGSpace(s2, harmonic=True)
v = np.empty(s1+s2,dtype=np.complex128)
v.real = np.random.random(s1+s2)
v.imag = np.random.random(s1+s2)
f1=Field(r2,val=v,copy=True)
f2=Field((ra,rb),val=v,copy=True)
h2,a2 = Field._hermitian_decomposition((RGSpace(s1, harmonic=True),
RGSpace(s2, harmonic=True)),f2.val,(0,1),ax2,False)
h1,a1 = Field._hermitian_decomposition((RGSpace(s1+s2, harmonic=True),),
f1.val,(0,),ax1,False)
assert(np.max(np.abs(h1-h2))<1e-10)
assert(np.max(np.abs(a1-a2))<1e-10)
#class Test_Initialization(unittest.TestCase):
#
# @parameterized.expand(
......
......@@ -155,16 +155,12 @@ class RGSpaceFunctionalityTests(unittest.TestCase):
@expand(product([(10,),(11,),(1,1),(4,4),(5,7),(8,12),(7,16),(4,6,8),
(17,5,3)],))
def test_hermitian_decomposition1(self, shape):
def test_hermitian_decomposition(self, shape):
r = RGSpace(shape, harmonic=True)
v = np.empty(shape,dtype=np.complex128)
v.real = np.random.random(shape)
v.imag = np.random.random(shape)
v=Field(r,val=v)
h,a = r.hermitian_decomposition(v.val)
v=v.val.get_full_data()
h=h.get_full_data()
a=a.get_full_data()
h,a = r.hermitian_decomposition(v)
# make sure that data == h + a
assert_almost_equal(v,h+a)
# test hermitianity of h
......@@ -176,24 +172,9 @@ class RGSpaceFunctionalityTests(unittest.TestCase):
i2.append(h.shape[i]-i1[i] if i1[i]>0 else 0)
i2 = tuple(i2)
assert_almost_equal(h[i1],np.conj(h[i2]))
assert_almost_equal(a[i1],-np.conj(a[i2]))
it.iternext()
def test_hermitian_decomposition2(self):
r2 = RGSpace((16,25), harmonic=True)
ra = RGSpace((16,), harmonic=True)
rb = RGSpace((25,), harmonic=True)
v = np.empty((16,25),dtype=np.complex128)
v.real = np.random.random((16,25))
v.imag = np.random.random((16,25))
f1=Field(r2,val=v,copy=True)
f2=Field((ra,rb),val=v,copy=True)
h2,a2 = Field._hermitian_decomposition((RGSpace((16,), harmonic=True),
RGSpace((25,), harmonic=True)),f2.val,(0,1),((0,),(1,),),False)
h1,a1 = Field._hermitian_decomposition((RGSpace((16,25), harmonic=True),),
f1.val,(0,),((0,1),),False)
assert(np.max(np.abs(h1-h2))<1e-10)
assert(np.max(np.abs(a1-a2))<1e-10)
@expand(get_distance_array_configs())
def test_distance_array(self, shape, distances, zerocenter, expected):
r = RGSpace(shape=shape, distances=distances, zerocenter=zerocenter)
......
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