From 2bb95ac8014e273370043589d92b1602d10817da Mon Sep 17 00:00:00 2001 From: Matteo Giantomassi Date: Fri, 24 Mar 2017 14:47:07 +0100 Subject: [PATCH] Close files, increase lpratio in unit tests --- abipy/core/skw.py | 1 - abipy/dfpt/tests/test_phonons.py | 2 +- abipy/electrons/scr.py | 2 +- abipy/electrons/tests/test_ebands.py | 7 +++++-- abipy/iotools/tests/test_xsf.py | 8 +++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/abipy/core/skw.py b/abipy/core/skw.py index c5782d2ba..5838ac4d2 100644 --- a/abipy/core/skw.py +++ b/abipy/core/skw.py @@ -799,7 +799,6 @@ def __init__(self, lpratio, kpts, eigens, fermie, nelect, cell, symrel, has_timr de_kbs[:, ib, spin] = eigens[spin, 0:nkpt-1, ib] - eigens[spin, nkpt-1, ib] # Solve all bands and spins at once - #call np.linalg.zhesv("U", nkpt-1, nband*nsppol, hmat, nkpt-1, ipiv, lmbs, nkpt-1, work, lwork, ierr) try: lmb_kbs = scipy.linalg.solve(hmat, np.reshape(de_kbs, (-1, nband * nsppol)), sym_pos=True, lower=False, overwrite_a=True, overwrite_b=True, check_finite=False) diff --git a/abipy/dfpt/tests/test_phonons.py b/abipy/dfpt/tests/test_phonons.py index a6593e3e9..c2e802d5e 100644 --- a/abipy/dfpt/tests/test_phonons.py +++ b/abipy/dfpt/tests/test_phonons.py @@ -85,6 +85,7 @@ def test_plot_functions(self): fig = phbands_gridplot(phb_objects, titles=["phonons1", "phonons2"], phdos_objects=phdos_objects, show=False) assert fig is not None + phdos.close() class PhbstFileTest(AbipyTest): @@ -164,7 +165,6 @@ class InteratomicForceConstantsTest(AbipyTest): @classmethod def setUpClass(cls): cls.ddb = DdbFile(os.path.join(test_dir, "AlAs_444_nobecs_DDB")) - cls.ifc = cls.ddb.anaget_ifc(ifcout=40, ngqpt=[4,4,4], verbose=1) @classmethod diff --git a/abipy/electrons/scr.py b/abipy/electrons/scr.py index 017ec796a..a9253892d 100644 --- a/abipy/electrons/scr.py +++ b/abipy/electrons/scr.py @@ -22,7 +22,7 @@ class WGGFunction(object): - """ + r""" Base class for two-point functions expressed in reciprocal space i.e. a matrix $A_{G,G'}(q, \omega)$ diff --git a/abipy/electrons/tests/test_ebands.py b/abipy/electrons/tests/test_ebands.py index 7abbd1648..4f74af816 100644 --- a/abipy/electrons/tests/test_ebands.py +++ b/abipy/electrons/tests/test_ebands.py @@ -136,9 +136,12 @@ def test_jdos(self): with self.assertRaises(ValueError): nscf_bands.get_ejdos(spin, 0, 4) + def test_ebands_skw_interpolation(self): + bands = ElectronBands.from_file(abidata.ref_file("si_scf_GSR.nc")) + # Test interpolate. - vertices_names=[((0.0, 0.0, 0.0), "G"), ((0.5, 0.5, 0.0), "M")] - r = bands.interpolate(lpratio=5, vertices_names=vertices_names, kmesh=[8, 8, 8], verbose=1) + vertices_names = [((0.0, 0.0, 0.0), "G"), ((0.5, 0.5, 0.0), "M")] + r = bands.interpolate(lpratio=10, vertices_names=vertices_names, kmesh=[8, 8, 8], verbose=1) assert r.ebands_kpath is not None assert r.ebands_kpath.kpoints.is_path assert not r.ebands_kpath.kpoints.is_ibz diff --git a/abipy/iotools/tests/test_xsf.py b/abipy/iotools/tests/test_xsf.py index fc002e6d8..f075b4b8b 100644 --- a/abipy/iotools/tests/test_xsf.py +++ b/abipy/iotools/tests/test_xsf.py @@ -38,6 +38,7 @@ def test_xsf_write_structure(self): """ tmp_file.seek(0) self.assertMultiLineEqual(tmp_file.read(), xsf_string) + tmp_file.close() def test_xsf_write_data(self): """Testing XSF file with datasets.""" @@ -86,6 +87,7 @@ def test_xsf_write_data(self): xsf_write_data(tmp_file, self.mgb2, cplx_data, cplx_mode="re") tmp_file.seek(0) self.assertMultiLineEqual(tmp_file.read(), xsf_string) + tmp_file.close() def test_bxsf_write(self): tmp_file = tempfile.TemporaryFile(mode="w+") @@ -141,8 +143,4 @@ def test_bxsf_write(self): print(xsf_string) self.maxDiff = None self.assertMultiLineEqual(s, xsf_string) - - -if __name__ == "__main__": - import unittest - unittest.main() + tmp_file.close()