Debian Codegraph @

test/data/testCore.py

raw
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (c) 2017, the cclib development team
4 #
5 # This file is part of cclib (http://cclib.github.io) and is distributed under
6 # the terms of the BSD 3-Clause License.
7
8 """Test logfiles with core electron data in cclib"""
9
10 import os
11 import unittest
12
13 import numpy
14
15 from cclib.parser.utils import PeriodicTable
16
17 from skip import skipForParser
18
19 __filedir__ = os.path.realpath(os.path.dirname(__file__))
20
21
22 class GenericCoreTest(unittest.TestCase):
23 """Generic core electrons unittest"""
24
25 coredict = {'Mo': 28, 'O':0, 'Cl':10}
26 charge = -2
27
28 @skipForParser('Turbomole','The parser is still being developed so we skip this test')
29 def testcorrect(self):
30 """Is coreelectrons equal to what it should be?"""
31 pt = PeriodicTable()
32 ans = []
33 for x in self.data.atomnos:
34 ans.append(self.coredict[pt.element[x]])
35 ans = numpy.array(ans, "i")
36 numpy.testing.assert_array_equal(self.data.coreelectrons, ans)
37
38 @skipForParser('Turbomole','The parser is still being developed so we skip this test')
39 def testcharge(self):
40 """Is the total charge correct?"""
41 self.assertEqual(self.data.charge, self.charge)
42
43
44 class ADFCoreTest(GenericCoreTest):
45 """Customized core electrons unittest"""
46
47 # For some reason ADF does not have a core in this test for chlorine atoms.
48 # This might be fixable in the input.
49 coredict = {'Mo': 28, 'O':0, 'Cl':0}
50
51 # These calculations were run on the neutral complex.
52 charge = 0
53
54
55 class JaguarCoreTest(GenericCoreTest):
56 """Customized core electrons unittest"""
57
58 # This test was done using LanL2DZ instead of the smaller variant.
59 coredict = {'Mo': 36, 'O':0, 'Cl':10}
60
61
62 if __name__=="__main__":
63
64 import sys
65 sys.path.insert(1, os.path.join(__filedir__, ".."))
66
67 from test_data import DataSuite
68 suite = DataSuite(['Suite'])
69 suite.testall()