From: <bao...@us...> - 2006-04-02 21:31:22
|
Revision: 44 Author: baoilleach Date: 2006-04-02 14:31:12 -0700 (Sun, 02 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=44&view=rev Log Message: ----------- Starting to use proper unit testing using the unittest module Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-03-27 21:40:25 UTC (rev 43) +++ trunk/test/testall.py 2006-04-02 21:31:12 UTC (rev 44) @@ -1,27 +1,44 @@ -import os -from cclib.parser import GAMESS,G03 +import os, unittest +from cclib.parser import GAMESS,G03,ADF +from Numeric import array -os.chdir(os.path.join("..","data")) +class GenericTest(unittest.TestCase): + def testhomos(self): + self.assertEquals(self.data.homos,array([34])) -testfiles = [G03(os.path.join("Gaussian","basicGaussian03","dvb_gopt.out")), - GAMESS(os.path.join("GAMESS","basicPCGAMESS","dvb_gopt_a.out"))] + def testnatom(self): + self.assertEquals(self.data.natom,20) -for testfile in testfiles: - testfile.logger.setLevel(0) - testfile.parse() + def testnbasis(self): + self.assertEquals(self.data.nbasis,60) -attribs = ['natom','homos','nbasis'] -for attrib in attribs: - print attrib, - for testfile in testfiles: - print testfile.__getattribute__(attrib), - print + def testscfenergy(self): + self.assert_(self.data.scfenergies[-1]+382.3<3) -print "Energy of optimised molecule", -for testfile in testfiles: - print testfile.scfenergies[-1], -print -print "Energy of HOMO", -for testfile in testfiles: - print testfile.moenergies[0,testfile.homos[0]], -print + def testhomoenergy(self): + self.assert_(self.data.moenergies[0,self.data.homos[0]]+4.165<0.5,"HOMO energy is %f (for G03 it's -4.165)" % self.data.moenergies[0,self.data.homos[0]]) + +class GaussianTest(GenericTest): + def setUp(self): + self.data = G03(os.path.join("..","data","Gaussian","basicGaussian03","dvb_gopt.out")) + self.data.logger.setLevel(0) + self.data.parse() + +class GamessTest(GenericTest): + def setUp(self): + self.data = GAMESS(os.path.join("..","data","GAMESS","basicPCGAMESS","dvb_gopt_a.out")) + self.data.logger.setLevel(0) + self.data.parse() + +class ADFTest(GenericTest): + def setUp(self): + self.data = ADF(os.path.join("..","data","ADF","basicADF2004.01","dvb_gopt.adfout")) + self.data.logger.setLevel(0) + self.data.parse() + +if __name__=="__main__": + gaussiantests = unittest.makeSuite(GaussianTest) + gamesstests = unittest.makeSuite(GamessTest) + adftests = unittest.makeSuite(ADFTest) + alltests = unittest.TestSuite((gaussiantests,gamesstests,adftests)) + unittest.TextTestRunner(verbosity=2).run(alltests) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-04-03 16:16:12
|
Revision: 51 Author: baoilleach Date: 2006-04-03 09:16:04 -0700 (Mon, 03 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=51&view=rev Log Message: ----------- Added convenience function to make it easier to access the data files in the data folder. Am considering changing all references to G03 or Gaussian03, to Gaussian, in line with GAMESS and ADF (which don't mention the specific version in the parser name). Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-04-03 15:52:28 UTC (rev 50) +++ trunk/test/testall.py 2006-04-03 16:16:04 UTC (rev 51) @@ -20,22 +20,32 @@ class GaussianTest(GenericTest): def setUp(self): - self.data = G03(os.path.join("..","data","Gaussian","basicGaussian03","dvb_gopt.out")) - self.data.logger.setLevel(0) - self.data.parse() + self.data = getfile(G03,"basicGaussian03","dvb_gopt.out") class GamessTest(GenericTest): def setUp(self): - self.data = GAMESS(os.path.join("..","data","GAMESS","basicPCGAMESS","dvb_gopt_a.out")) - self.data.logger.setLevel(0) - self.data.parse() + self.data = getfile(GAMESS,"basicPCGAMESS","dvb_gopt_a.out") class ADFTest(GenericTest): def setUp(self): - self.data = ADF(os.path.join("..","data","ADF","basicADF2004.01","dvb_gopt.adfout")) - self.data.logger.setLevel(0) - self.data.parse() + self.data = getfile(ADF,"basicADF2004.01","dvb_gopt.adfout") + +def getfile(parser,*location): + """Returns a parsed logfile.""" + if parser.__name__ in ['GAMESS','ADF']: + fullpath = ("..","data",parser.__name__) + location + elif parser.__name__=="G03": + fullpath = ("..","data","Gaussian") + location + logfile = parser(os.path.join(*fullpath)) + logfile.logger.setLevel(0) + logfile.parse() + return logfile + +def visualtests(): + """These are not formal tests -- but they should be eyeballed.""" + pass + if __name__=="__main__": gaussiantests = unittest.makeSuite(GaussianTest) gamesstests = unittest.makeSuite(GamessTest) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-04-03 20:09:53
|
Revision: 52 Author: baoilleach Date: 2006-04-03 13:09:44 -0700 (Mon, 03 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=52&view=rev Log Message: ----------- Added tests for looking at the energies of the homo/lumo. These values don't at all agree across packages - is this a program with units or what? Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-04-03 16:16:04 UTC (rev 51) +++ trunk/test/testall.py 2006-04-03 20:09:44 UTC (rev 52) @@ -2,31 +2,32 @@ from cclib.parser import GAMESS,G03,ADF from Numeric import array -class GenericTest(unittest.TestCase): +class GenericGeoOptTest(unittest.TestCase): def testhomos(self): + """Is the index of the homo equal to 34?""" self.assertEquals(self.data.homos,array([34])) def testnatom(self): + """Is the number of atoms equal to 20?""" self.assertEquals(self.data.natom,20) def testnbasis(self): + """Is the number of basis set function equal to 60?""" self.assertEquals(self.data.nbasis,60) def testscfenergy(self): + """Is the SCF energy within 3eV(?) of -382.3?""" self.assert_(self.data.scfenergies[-1]+382.3<3) - def testhomoenergy(self): - self.assert_(self.data.moenergies[0,self.data.homos[0]]+4.165<0.5,"HOMO energy is %f (for G03 it's -4.165)" % self.data.moenergies[0,self.data.homos[0]]) - -class GaussianTest(GenericTest): +class GaussianGeoOptTest(GenericGeoOptTest): def setUp(self): self.data = getfile(G03,"basicGaussian03","dvb_gopt.out") -class GamessTest(GenericTest): +class GamessGeoOptTest(GenericGeoOptTest): def setUp(self): self.data = getfile(GAMESS,"basicPCGAMESS","dvb_gopt_a.out") -class ADFTest(GenericTest): +class ADFGeoOptTest(GenericGeoOptTest): def setUp(self): self.data = getfile(ADF,"basicADF2004.01","dvb_gopt.adfout") @@ -43,12 +44,26 @@ def visualtests(): """These are not formal tests -- but they should be eyeballed.""" - pass + logfiles = [ getfile(G03,"basicGaussian03","dvb_gopt.out"), + getfile(GAMESS,"basicPCGAMESS","dvb_gopt_a.out"), + getfile(ADF,"basicADF2004.01","dvb_gopt.adfout") ] + + print "\n\nMO energies of optimised dvb" + print " ","".join(["%7s" % x for x in ['Gaussian','GAMESS','ADF']]) + print "HOMO", " ".join(["%+2.4f" % x.moenergies[0,x.homos[0]] for x in logfiles]) + print "LUMO", " ".join(["%+2.4f" % x.moenergies[0,x.homos[0]+1] for x in logfiles]) + print "H-L ", " ".join(["%2.4f" % (x.moenergies[0,x.homos[0]+1]-x.moenergies[0,x.homos[0]],) for x in logfiles]) if __name__=="__main__": - gaussiantests = unittest.makeSuite(GaussianTest) - gamesstests = unittest.makeSuite(GamessTest) - adftests = unittest.makeSuite(ADFTest) - alltests = unittest.TestSuite((gaussiantests,gamesstests,adftests)) - unittest.TextTestRunner(verbosity=2).run(alltests) + gaussiantests = unittest.makeSuite(GaussianGeoOptTest) + gamesstests = unittest.makeSuite(GamessGeoOptTest) + adftests = unittest.makeSuite(ADFGeoOptTest) + print "\n*** Testing Gaussian dvb_gopt.out ***" + unittest.TextTestRunner(verbosity=2).run(gaussiantests) + print "\n\n*** Testing GAMESS dvb_gopt_a.out ***" + unittest.TextTestRunner(verbosity=2).run(gamesstests) + print "\n\n*** Testing ADF dvb_gopt.adfout ***" + unittest.TextTestRunner(verbosity=2).run(adftests) + print "\n\n*** Visual tests ***" + visualtests() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-04-15 09:07:30
|
Revision: 70 Author: baoilleach Date: 2006-04-15 02:07:25 -0700 (Sat, 15 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=70&view=rev Log Message: ----------- Added some more tests: for the correct symmetry labels, and the correct number of evalues Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-04-15 08:40:26 UTC (rev 69) +++ trunk/test/testall.py 2006-04-15 09:07:25 UTC (rev 70) @@ -23,6 +23,15 @@ """Did this subclasses overwrite normalisesym?""" self.assertNotEquals(self.data.normalisesym("A"),"ERROR: This should be overwritten by this subclass") + def testlengthmosyms(self): + """Is the number of evalues equal to 60?""" + self.assertEquals(60,len(self.data.moenergies[0])) + + def testsymlabels(self): + """Are all the symmetry labels either Ag/u or Bg/u?""" + sumwronglabels = sum([x not in ['Ag','Bu','Au','Bg'] for x in self.data.mosyms[0]]) + self.assertEquals(sumwronglabels,0) + class GaussianGeoOptTest(GenericGeoOptTest): def setUp(self): self.data = getfile(G03,"basicGaussian03","dvb_gopt.out") @@ -63,13 +72,11 @@ getfile(Jaguar,"basicJaguar","eg01","dvb_gopt.out")] print "\n\nMO energies of optimised dvb" - print " ","".join(["%8s" % x for x in ['Gaussian','PCGAMESS','GAMESS-US','ADF']]) + print " ","".join(["%8s" % x for x in ['Gaussian','PCGAMESS','GAMESS-US','ADF','Jaguar']]) print "HOMO", " ".join(["%+2.4f" % x.moenergies[0,x.homos[0]] for x in logfiles]) print "LUMO", " ".join(["%+2.4f" % x.moenergies[0,x.homos[0]+1] for x in logfiles]) print "H-L ", " ".join(["%2.4f" % (x.moenergies[0,x.homos[0]+1]-x.moenergies[0,x.homos[0]],) for x in logfiles]) - for x in logfiles: - print x.mosyms if __name__=="__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-04-15 09:12:24
|
Revision: 71 Author: baoilleach Date: 2006-04-15 02:12:20 -0700 (Sat, 15 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=71&view=rev Log Message: ----------- Mispelling Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-04-15 09:07:25 UTC (rev 70) +++ trunk/test/testall.py 2006-04-15 09:12:20 UTC (rev 71) @@ -23,7 +23,7 @@ """Did this subclasses overwrite normalisesym?""" self.assertNotEquals(self.data.normalisesym("A"),"ERROR: This should be overwritten by this subclass") - def testlengthmosyms(self): + def testlengthmoenergies(self): """Is the number of evalues equal to 60?""" self.assertEquals(60,len(self.data.moenergies[0])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-04-22 09:24:12
|
Revision: 79 Author: baoilleach Date: 2006-04-22 02:24:03 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=79&view=rev Log Message: ----------- New test for scfvalues to ensure that it has (a) right dimensions compared to geovalues and scftargets and (b) is the correct type: a list of Numeric arrays Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-04-21 07:10:27 UTC (rev 78) +++ trunk/test/testall.py 2006-04-22 09:24:03 UTC (rev 79) @@ -32,6 +32,14 @@ sumwronglabels = sum([x not in ['Ag','Bu','Au','Bg'] for x in self.data.mosyms[0]]) self.assertEquals(sumwronglabels,0) + def testscfvaluetype(self): + """Do the scf values have the right type?""" + self.assert_(type(self.data.scfvalues[0])==type(array([])) and type(self.data.scfvalues)==type([])) + + def testscfvaluedim(self): + """Do the scf values have the right dimensions?""" + self.assert_(len(self.data.scfvalues)==len(self.data.geovalues) and len(self.data.scfvalues[0])==len(self.data.scftargets)) + class GaussianGeoOptTest(GenericGeoOptTest): def setUp(self): self.data = getfile(G03,"basicGaussian03","dvb_gopt.out") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-05-03 09:14:19
|
Revision: 98 Author: baoilleach Date: 2006-05-03 02:14:12 -0700 (Wed, 03 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=98&view=rev Log Message: ----------- Tided up the main section, in preparation for adding tests for single point unrestricted. Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-05-03 08:44:14 UTC (rev 97) +++ trunk/test/testall.py 2006-05-03 09:14:12 UTC (rev 98) @@ -93,20 +93,21 @@ if __name__=="__main__": - gaussiantests = unittest.makeSuite(GaussianGeoOptTest) - pcgamesstests = unittest.makeSuite(PCGamessGeoOptTest) - gamessustests = unittest.makeSuite(GamessUSGeoOptTest) - adftests = unittest.makeSuite(ADFGeoOptTest) - jaguartests = unittest.makeSuite(JaguarGeoOptTest) - print "\n*** Testing Gaussian dvb_gopt.out ***" - unittest.TextTestRunner(verbosity=2).run(gaussiantests) - print "\n\n*** Testing PCGAMESS dvb_gopt_a.out ***" - unittest.TextTestRunner(verbosity=2).run(pcgamesstests) - print "\n\n*** Testing GAMESS-US dvb_gopt_a.out ***" - unittest.TextTestRunner(verbosity=2).run(gamessustests) - print "\n\n*** Testing ADF dvb_gopt.adfout ***" - unittest.TextTestRunner(verbosity=2).run(adftests) - print "\n\n*** Testing Jaguar dvb_gopt.out ***" - unittest.TextTestRunner(verbosity=2).run(jaguartests) + names = [ "Gaussian", "PCGamess", "GAMESS", "ADF", "Jaguar" ] + tests = [ GaussianGeoOptTest, PCGamessGeoOptTest, + GamessUSGeoOptTest, ADFGeoOptTest, + JaguarGeoOptTest ] + total = errors = failures = 0 + for name,test in zip(names,tests): + print "\n**** Testing %s Geo Opt ****" % name + myunittest = unittest.makeSuite(test) + a = unittest.TextTestRunner(verbosity=2).run(myunittest) + total += a.testsRun + errors += len(a.errors) + failures += len(a.failures) + + print "\n\n********* SUMMARY OF EVERYTHING **************" + print "TOTAL: %d\tPASSED: %d\tFAILED: %d\tERRORS: %d" % (total,total-(errors+failures),failures,errors) + print "\n\n*** Visual tests ***" visualtests() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2006-05-09 16:10:52
|
Revision: 101 Author: baoilleach Date: 2006-05-09 09:10:39 -0700 (Tue, 09 May 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=101&view=rev Log Message: ----------- Adding some tests for the dimensions of aooverlaps and mocoeffs in restricted single point energy calculations -- what's the story with ADF though? Modified Paths: -------------- trunk/test/testall.py Modified: trunk/test/testall.py =================================================================== --- trunk/test/testall.py 2006-05-09 01:11:45 UTC (rev 100) +++ trunk/test/testall.py 2006-05-09 16:10:39 UTC (rev 101) @@ -2,6 +2,32 @@ from cclib.parser import GAMESS,G03,ADF,Jaguar from Numeric import array +class GenericSPTest(unittest.TestCase): + """Restricted single point calculations with MO coeffs and overlap info.""" + def testdimaooverlaps(self): + """Are the dims of the overlap matrix consistent with nbasis?""" + self.assertEquals(self.data.aooverlaps.shape,(self.data.nbasis,self.data.nbasis)) + + def testdimmocoeffs(self): + """Are the dimensions of mocoeffs equal to 1 x nindep x nbasis?""" + self.assertEquals(self.data.mocoeffs.shape,(1,self.data.nindep,self.data.nbasis)) + +class GaussianSPTest(GenericSPTest): + def setUp(self): + self.data = getfile(G03,"basicGaussian03","dvb_sp.out") + +class GamessUSSPTest(GenericSPTest): + def setUp(self): + self.data = getfile(GAMESS,"basicGAMESS-US","dvb_sp.out") + +class PCGamessSPTest(GenericSPTest): + def setUp(self): + self.data = getfile(GAMESS,"basicPCGAMESS","dvb_sp.out") + +class ADFSPTest(GenericSPTest): + def setUp(self): + self.data = getfile(ADF,"basicADF2004.01","dvb_sp_b.adfout") + class GenericGeoOptTest(unittest.TestCase): def testhomos(self): """Is the index of the homo equal to 34?""" @@ -106,6 +132,16 @@ errors += len(a.errors) failures += len(a.failures) + tests = [ GaussianSPTest, PCGamessSPTest, + GamessUSSPTest, ADFSPTest ] + for name,test in zip(names,tests): + print "\n**** Testing %s SP ****" % name + myunittest = unittest.makeSuite(test) + a = unittest.TextTestRunner(verbosity=2).run(myunittest) + total += a.testsRun + errors += len(a.errors) + failures += len(a.failures) + print "\n\n********* SUMMARY OF EVERYTHING **************" print "TOTAL: %d\tPASSED: %d\tFAILED: %d\tERRORS: %d" % (total,total-(errors+failures),failures,errors) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bao...@us...> - 2007-09-02 20:26:31
|
Revision: 743 http://cclib.svn.sourceforge.net/cclib/?rev=743&view=rev Author: baoilleach Date: 2007-09-02 13:26:25 -0700 (Sun, 02 Sep 2007) Log Message: ----------- testall: Now can take the name of a parser, so it's possible to just run the tests for a particular parser. Note to self: need to combine testmodule() and testall() as there is duplication. Modified Paths: -------------- trunk/test/testall.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <la...@us...> - 2007-10-29 12:10:52
|
Revision: 780 http://cclib.svn.sourceforge.net/cclib/?rev=780&view=rev Author: langner Date: 2007-10-29 05:10:50 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Removed Jaguar4.2 from visual tests and added Molpro. Modified Paths: -------------- trunk/test/testall.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |