# Jaguar prints only 10 virtual MOs by default. Can we re-run with full output? def testlengthmoenergies(self): """Is the number of evalues equal to the number of occ. MOs + 10?""" self.assertEquals(len(self.data.moenergies[0]), self.data.homos[0]+11) class Psi3SPTest(GenericSPTest): """Customized restricted single point HF/KS unittest""" # The final energy is also a bit higher here, I think due to the fact # that a SALC calculation is done instead of a full LCAO. b3lyp_energy = -10300 class OrcaSPTest(GenericSPTest): """Customized restricted single point unittest""" # Orca has different weights for the masses molecularmass = 130190 if __name__=="__main__": import sys sys.path.insert(1, os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['SP']) suite.testall()
self.assertEqual(len(self.data.etoscs), self.number) def testrotatsnumber(self): """Is the length of etrotats correct?""" self.assertEqual(len(self.data.etrotats), self.number) def testsecsnumber(self): """Is the length of etsecs correct?""" self.assertEqual(len(self.data.etsecs), self.number) def testsymsnumber(self): """Is the length of etsyms correct?""" self.assertEqual(len(self.data.etsyms), self.number) def testsyms(self): """Is etsyms populated by singlets and triplets 50/50?""" singlets = [sym for sym in self.data.etsyms if "Singlet" in sym] triplets = [sym for sym in self.data.etsyms if "Triplet" in sym] self.assertEqual(len(singlets), self.number / 2) self.assertEqual(len(triplets), self.number / 2) if __name__ == "__main__": import sys sys.path.insert(1, os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['TDun']) suite.testall()
"""Test coupled cluster logfiles""" import os import unittest import numpy from skip import skipForParser __filedir__ = os.path.realpath(os.path.dirname(__file__)) class GenericCCTest(unittest.TestCase): """Generic coupled cluster unittest""" @skipForParser('Molcas', 'The parser is still being developed so we skip this test') def testsign(self): """Are the coupled cluster corrections negative?""" corrections = self.data.ccenergies - self.data.scfenergies self.failUnless(numpy.alltrue(corrections < 0.0)) if __name__ == "__main__": import sys sys.path.insert(1, os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['CC']) suite.testall()
len(self.data.optdone)) for idone in self.data.optdone: self.assertOptDone(self.data.optstatus[idone]) if idone != len(self.data.optstatus) - 1: self.assertOptNew(self.data.optstatus[idone + 1]) class GaussianScanTest(GenericScanTest): """Customized relaxed potential energy surface scan unittest""" extra = 1 class JaguarScanTest(GenericScanTest): """Customized relaxed potential energy surface scan unittest""" extra = 1 class OrcaScanTest(GenericScanTest): """Customized relaxed potential energy surface scan unittest""" extra = 1 if __name__ == "__main__": import sys sys.path.append(os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['Scan']) suite.testall()
class MolcasBigBasisTest(GenericBigBasisTest): """Customized big basis set unittest""" spherical = True class MolproBigBasisTest(GenericBigBasisTest): """Customized big basis set unittest""" spherical = True class Psi4BigBasisTest(GenericBigBasisTest): """Customized big basis set unittest""" spherical = True class QChemBigBasisTest(GenericBigBasisTest): """Customized big basis set unittest""" spherical = True if __name__ == "__main__": import sys sys.path.insert(1, os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['Basis']) suite.testall()
# Psi has a number of different convergence strategies to choose from, as described here: # http://sirius.chem.vt.edu/psi4manual/latest/optking.html # and the default is to check that the max. force is converged and if the max energy change # or dispalcement is converged. This is in fact what is tested below. def testoptdone(self): """Has the geometry converged and set optdone to True?""" self.assertTrue(self.data.optdone) targets = self.data.geotargets values = numpy.abs(self.data.geovalues[-1]) # Since the other criteria are not used and are not printed in this case, they should # be parsed as numpy.inf, for which we can check. self.assertTrue(numpy.isinf(targets[2])) self.assertTrue(numpy.isinf(targets[4])) conv = values[1] < targets[1] and (values[0] < targets[0] or values[3] < targets[3]) self.assertTrue(conv) if __name__ == "__main__": import sys sys.path.append(os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['GeoOpt']) suite.testall()
@skipForParser('Molcas','The parser is still being developed so we skip this test') @skipForParser('Turbomole','The parser is still being developed so we skip this test') def testisotropic(self): """Is the isotropic polarizability (average of the diagonal elements) +/- 0.01 from a reference? """ isotropic = numpy.average(numpy.diag(self.data.polarizabilities[0])) self.assertAlmostEqual(isotropic, self.isotropic, delta=self.isotropic_delta) @skipForParser('Molcas','The parser is still being developed so we skip this test') @skipForParser('Turbomole','The parser is still being developed so we skip this test') def testprincomponents(self): """Are each of the principal components (eigenvalues) of the polarizability tensor +/- 0.01 from a reference? """ principal_components = numpy.linalg.eigvalsh(self.data.polarizabilities[0]) for c in range(3): self.assertAlmostEqual(principal_components[c], self.principal_components[c], delta=self.principal_components_delta) if __name__=="__main__": import sys sys.path.insert(1, os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['Polar']) suite.testall()
"""Customized Raman unittest""" max_raman_intensity = 745 class GaussianRamanTest(GenericRamanTest): """Customized Raman unittest""" max_raman_intensity = 1066 class OrcaRamanTest(GenericRamanTest): """Customized Raman unittest""" max_raman_intensity = 1045 class QChemRamanTest(GenericRamanTest): """Customized Raman unittest""" max_raman_intensity = 588 if __name__=="__main__": import sys sys.path.insert(1, os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['vib']) suite.testall()
def testdimatomcoords(self): """Are the number of parsed geometries consistent with the number of MD steps? """ self.assertEqual(self.data.atomcoords.shape, (self.nenergies, 20, 3)) def testdimtime(self): """Are the number of time points consistent with the number of MD steps? """ self.assertEqual(self.data.time.shape, (self.nsteps, )) class GaussianBOMDTest(GenericBOMDTest): """Customized Born-Oppenheimer molecular dynamics unittest""" # This may have something to do with our corrections for # extrapolation step rejection. nenergies = 35 if __name__ == "__main__": import sys sys.path.append(os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['BOMD']) suite.testall()
(self.number, self.data.natom, 3, 3)) class GaussianHTTest(GenericHTTest): """Customized TD/CIS num freq HT unittest""" def testetveleltrdipgradsshape(self): """Is etveleltrdipgrads the right shape?""" self.assertEqual(numpy.shape(self.data.etveleltrdipgrads), (self.number, self.data.natom, 3, 3)) def testetmagtrdipgradsshape(self): """Is etmagtrdipgrads the right shape?""" self.assertEqual(numpy.shape(self.data.etmagtrdipgrads), (self.number, self.data.natom, 3, 3)) class GaussianfcHTTest(GaussianHTTest): """Customized TD/CIS num freq HT unittest""" number = 1 # fchk only contains HT grads for root of interest if __name__ == "__main__": import sys sys.path.append(os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['HT']) suite.testall()
# This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. """Test NMR logfiles in cclib.""" import os import unittest from skip import skipForParser __filedir__ = os.path.realpath(os.path.dirname(__file__)) class GenericNMRTest(unittest.TestCase): """Generic NMR unittest""" def testsize(self): """Check to make sure there are the correct number of tensors parsed""" self.assertEqual(len(self.data.nmrtensors), self.data.natom) self.assertEqual(len(self.data.nmrtensors[0]), 3) self.assertEqual(self.data.nmrtensors[0]["total"].shape, (3, 3)) if __name__ == "__main__": import sys sys.path.insert(1, os.path.join(__filedir__, "..")) from test_data import DataSuite suite = DataSuite(['NMR']) suite.testall()
# to classes dynamically (bad idea), so they get overwritten when we reuse # classes for unittests. See bellow how we collect ccData instances to sidestep # this issue; although that doesn't alleviate the issue entirely, and the fix # needs to happen in the cclib code. try: from test_data import parser_names from test_data import DataSuite thispath = os.path.dirname(os.path.realpath(__file__)) logpath = thispath + "/coverage.tests.log" try: with open(logpath, "w") as flog: stdout_backup = sys.stdout sys.stdout = flog alltests = {} for p in parser_names: suite = DataSuite(argv=[p], stream=flog) suite.testall() alltests[p] = [{'data': t.data} for t in suite.alltests] sys.stdout = stdout_backup except Exception as e: print("Unit tests did not run correctly. Check log file for errors:") print(open(logpath, 'r').read()) print(e) sys.exit(1) except ImportError: from testall import parsers as parser_names from testall import testall thispath = os.path.dirname(os.path.realpath(__file__)) logpath = thispath + "/coverage.tests.log" try:
from test_data import all_parsers from test_data import parser_names from test_data import DataSuite import inspect ds_args = inspect.getargspec(DataSuite.__init__).args thispath = os.path.dirname(os.path.realpath(__file__)) logpath = thispath + "/coverage.tests.log" try: with open(logpath, "w") as flog: stdout_backup = sys.stdout sys.stdout = flog alltests = {} for p in parser_names: # newer versions, changed in rev 17b5b263 if 'parsers' in ds_args: suite = DataSuite(parsers={p: all_parsers[p]}, modules=all_modules, stream=flog) else: assert 'argv' in ds_args suite = DataSuite(argv=[p], stream=flog) suite.testall() alltests[p] = [{'data': t.data} for t in suite.alltests] sys.stdout = stdout_backup except Exception as e: print("Unit tests did not run correctly. Check log file for errors:") print(open(logpath, 'r').read()) print(e) sys.exit(1) except ImportError: from testall import parsers as parser_names from testall import testall