def testPermute(self):
        for i in xrange(100):
            coords2 = np.random.random(3*20)
            coords = coords2.copy().reshape([-1,3])
            coords3 = coords2.copy()
            transform = TransformCluster3D(nsites=20)
            transform2 = TransformCluster3D(nsites=20)
            
            perm = random_permutation(20)
            transform.permute(perm)
            coords = coords[perm]
            transform2.transform(TransformCluster3D(nsites=20).permute(perm))
            
            perm = random_permutation(20)
            transform.permute(perm)
            coords = coords[perm]
            transform2.transform(TransformCluster3D(nsites=20).permute(perm))

            transform.apply(coords2)
            transform2.apply(coords3)
            
            self.assertLess(np.linalg.norm(coords2 - coords.flatten()), 1e-10)
            self.assertLess(np.linalg.norm(coords3 - coords.flatten()), 1e-10)
Esempio n. 2
0
    def testPermute(self):
        for i in xrange(100):
            coords2 = np.random.random(3 * 20)
            coords = coords2.copy().reshape([-1, 3])
            coords3 = coords2.copy()
            transform = TransformCluster3D(nsites=20)
            transform2 = TransformCluster3D(nsites=20)

            perm = random_permutation(20)
            transform.permute(perm)
            coords = coords[perm]
            transform2.transform(TransformCluster3D(nsites=20).permute(perm))

            perm = random_permutation(20)
            transform.permute(perm)
            coords = coords[perm]
            transform2.transform(TransformCluster3D(nsites=20).permute(perm))

            transform.apply(coords2)
            transform2.apply(coords3)

            self.assertLess(np.linalg.norm(coords2 - coords.flatten()), 1e-10)
            self.assertLess(np.linalg.norm(coords3 - coords.flatten()), 1e-10)
Esempio n. 3
0
 def rperm(self, tform, coords):
     """apply random permutation to both coords and transformation object"""
     perm = _utils.random_permutation(len(coords) / 3)
     tform.permute(perm)
     self.policy.permute(coords, perm)
Esempio n. 4
0
    def test_apply_permutation(self):
        rot = _utils.random_permutation(self.natoms)

        _utils.permute(self.x2, rot)
        self.tform.apply_permutation(self.x, rot)
        self.assertLess(np.abs(self.x - self.x2).max(), 1e-3)
Esempio n. 5
0
 def rperm(self, tform, coords):
     """apply random permutation to both coords and transformation object"""
     perm = _utils.random_permutation(len(coords) / 3)
     tform.permute(perm)
     self.policy.permute(coords, perm)
Esempio n. 6
0
    def test_apply_permutation(self):
        rot = _utils.random_permutation(self.natoms)

        _utils.permute(self.x2, rot)
        self.tform.apply_permutation(self.x, rot)
        self.assertLess(np.abs(self.x - self.x2).max(), 1e-3)