Coverage for gpaw/test/matrix/test_tril2full.py: 100%
25 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
1import pytest
2from gpaw.core.matrix import Matrix
3from gpaw.mpi import broadcast_exception, world
6@pytest.mark.parametrize('dtype', [float, complex])
7def test_tril2full(dtype, rng):
8 N = 21
9 S0 = Matrix(N, N, dist=(world, 1, 1), dtype=dtype)
10 S = S0.new(dist=(world, world.size, 1))
11 if world.rank == 0:
12 S0.data[:] = rng.random((N, N))
13 if dtype == complex:
14 S0.data.imag[:] = rng.random((N, N))
15 S0.data.ravel().imag[::N + 1] = 0.0
16 S0.redist(S)
17 B = S.copy()
18 S.tril2full()
19 S.redist(S0)
20 with broadcast_exception(world):
21 if world.rank == 0:
22 assert abs(S0.data - S0.data.T.conj()).max() == 0.0
23 B.add_hermitian_conjugate(0.5)
24 B.redist(S0)
25 with broadcast_exception(world):
26 if world.rank == 0:
27 assert abs(S0.data - S0.data.T.conj()).max() == 0.0