Skip to content

Commit

Permalink
Additional tests for evec_load
Browse files Browse the repository at this point in the history
  • Loading branch information
chazeon committed Apr 18, 2021
1 parent 3651fec commit 25f4ed7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_cij_misc_evec_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,26 @@ def test_evec_load_basic(fname, nq, nbnd):
assert len(modes) == nbnd
for (mode_id, thz, cm_1), vec in modes:
assert len(vec) == nbnd


@pytest.mark.parametrize("key, fname", [(k, Path(__file__).parent / "data" / f) for k, f in test_files.items()])
@pytest.mark.parametrize("nq, nbnd", [(2, 60)])
def test_evec_load_normality(key, fname, nq, nbnd):
evecs = evec_load(fname, nq, nbnd)
for q_coord, modes in evecs:
eigs = numpy.array([modes[ibnd][1] for ibnd in range(nbnd)])
A = numpy.abs(numpy.conj(eigs) @ eigs.T)
assert numpy.allclose(numpy.diag(A), 1)


@pytest.mark.parametrize("key, fname", [(k, Path(__file__).parent / "data" / f) for k, f in test_files.items()])
@pytest.mark.parametrize("nq, nbnd", [(2, 60)])
def test_evec_load_orthogonal(key, fname, nq, nbnd):
evecs = evec_load(fname, nq, nbnd)
for q_coord, modes in evecs:
eigs = numpy.array([modes[ibnd][1] for ibnd in range(nbnd)])
A = numpy.abs(numpy.conj(eigs) @ eigs.T)
if key == "eig":
assert numpy.allclose(numpy.max(A - numpy.eye(nbnd)), 0, atol=1e-4)
elif key == "vec":
assert not numpy.allclose(numpy.max(A - numpy.eye(nbnd)), 0, atol=1e-4)

0 comments on commit 25f4ed7

Please sign in to comment.