common_aev_test.py 885 Bytes
Newer Older
Gao, Xiang's avatar
Gao, Xiang committed
1
2
import torch
import torchani
Gao, Xiang's avatar
Gao, Xiang committed
3
import os
Gao, Xiang's avatar
Gao, Xiang committed
4
5


6
class _TestAEVBase(torchani.testing.TestCase):
Gao, Xiang's avatar
Gao, Xiang committed
7
8

    def setUp(self):
Gao, Xiang's avatar
Gao, Xiang committed
9
10
11
12
        path = os.path.dirname(os.path.realpath(__file__))
        const_file = os.path.join(path, '../torchani/resources/ani-1x_8x/rHCNO-5.2R_16-3.5A_a4-8.params')  # noqa: E501
        consts = torchani.neurochem.Constants(const_file)
        self.aev_computer = torchani.AEVComputer(**consts)
Gao, Xiang's avatar
Gao, Xiang committed
13
14
15
        self.radial_length = self.aev_computer.radial_length
        self.debug = False

16
    def assertAEVEqual(self, expected_radial, expected_angular, aev):
Gao, Xiang's avatar
Gao, Xiang committed
17
18
19
20
        radial = aev[..., :self.radial_length]
        angular = aev[..., self.radial_length:]
        if self.debug:
            aid = 1
21
22
23
            print(torch.stack([expected_radial[0, aid, :], radial[0, aid, :]]))
        self.assertEqual(expected_radial, radial)
        self.assertEqual(expected_angular, angular)