From 25f4ed79767253da6176fe6c5f371b3ddbfd1008 Mon Sep 17 00:00:00 2001 From: Chazeon Date: Sun, 18 Apr 2021 00:10:13 -0400 Subject: [PATCH] Additional tests for evec_load --- tests/test_cij_misc_evec_load.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_cij_misc_evec_load.py b/tests/test_cij_misc_evec_load.py index 9ae6834..24310eb 100644 --- a/tests/test_cij_misc_evec_load.py +++ b/tests/test_cij_misc_evec_load.py @@ -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)