Exemplo n.º 1
0
 def test_rmsd_to_self(self):
     cs1 = LineSegmentStorage(["s0", "s1", "s2"])
     for r in range(RANDOM_REPETITIONS):
         cs1["s0"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
         cs1["s1"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
         cs1["s2"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
         self.assertAlmostEqual(cs1.rmsd_to(cs1), 0)
Exemplo n.º 2
0
 def test_rmsd_to_offset_unordered(self):
     cs1 = LineSegmentStorage(["s0", "s1", "s2"])
     cs2 = LineSegmentStorage(["s2", "s0", "s1"])
     cs1["s0"] = [0, 0, 0.], [0, 0, 3.]
     cs1["s1"] = [1, 1, 3.], [1, -1, -3.]
     cs1["s2"] = [0., 0., 0.], [1, -1, -3.]
     cs2["s0"] = [0, 0, 1.], [0, 0, 4.]
     cs2["s1"] = [1, 1, 4.], [1, -1, -2.]
     cs2["s2"] = [0., 0., 1.], [1, -1, -2.]
     self.assertAlmostEqual(cs1.rmsd_to(cs2), 0)
Exemplo n.º 3
0
    def test_rmsd_to_deviating(self):
        cs1 = LineSegmentStorage(["s0", "s1", "s2", "s3"])
        cs2 = LineSegmentStorage(["s2", "s0", "s3", "s1"])
        cs1["s0"] = [0, 0, 0.], [0, 0, 3.]
        cs1["s1"] = [1, 1, 3.], [1, -1, -3.]
        cs1["s2"] = [0., 0., 0.], [1, -1, -3.]
        cs1["s3"] = [0., 10., 0.], [1, -1, -3.]

        cs2["s0"] = [0, 0, 3.], [0, 0, 0.]
        cs2["s1"] = [1, -1, -3.], [1, 1, 3.]
        cs2["s2"] = [-1., -1., -3.], [0, 0, 0.]
        cs2["s3"] = [0., 5., 0.], [1, -1, -3.]
        self.assertGreater(cs1.rmsd_to(cs2), 1)
        self.assertLess(cs1.rmsd_to(cs2), 5)
Exemplo n.º 4
0
    def test_elements_closer_than_ignore(self):
        cs = LineSegmentStorage(["s0", "s1", "s2"])
        cs["s0"] = [0, 0, 0.], [0, 0, 3.]
        cs["s1"] = [1, 1, 3.], [1, -1, -3.]
        cs["s2"] = [0., 0., 0.], [1, -1, -3.]

        self.assertEqual(cs.elements_closer_than(
            1.5, ignore=set([("s0", "s2"), ("s2", "s1")])), [("s0", "s1")])
        self.assertEqual(cs.elements_closer_than(0.4),
                         [("s0", "s2"), ("s1", "s2")])
        self.assertEqual(cs.elements_closer_than(
            0.4, ignore=set([("s0", "s2"), ("s2", "s1")])), [])
        self.assertEqual(cs.elements_closer_than(
            0.4, ignore=[("s2", "s0")]), [("s1", "s2")])
Exemplo n.º 5
0
    def test_rmsd_to_is_a_symmetric_relation(self):
        cs1 = LineSegmentStorage(["s0", "m3", "s1", "i0", "s2"])
        cs2 = LineSegmentStorage(["s0", "s1", "s2", "i0", "m3"])

        for r in range(RANDOM_REPETITIONS):
            cs1["s0"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs1["s1"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs1["s2"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs1["i0"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs1["m3"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs2["s0"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs2["s1"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs2["s2"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs2["i0"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            cs2["m3"] = [rand(), rand(), rand()], [rand(), rand(), rand()]
            self.assertAlmostEqual(cs1.rmsd_to(cs2), cs2.rmsd_to(cs1))
Exemplo n.º 6
0
    def test_rmsd_to_rotated_ordered_unordered(self):
        cs1 = LineSegmentStorage(["s0", "s1", "s2"])
        cs2 = LineSegmentStorage(["s2", "s0", "s1"])
        cs1["s0"] = [0, 0, 0.], [0, 0, 3.]
        cs1["s1"] = [1, 1, 3.], [1, -1, -3.]
        cs1["s2"] = [0., 0., 0.], [1, -1, -3.]
        cs_temp = copy.deepcopy(cs1)
        cs_temp.rotate(
            np.array([[1, 0, 0], [0, cos(1.2), -sin(1.2)], [0, sin(1.2), cos(1.2)]]))

        self.assertAlmostEqual(cs1.rmsd_to(cs_temp), 0)

        cs2["s0"] = cs_temp["s0"]
        cs2["s1"] = cs_temp["s1"]
        cs2["s2"] = cs_temp["s2"]

        self.assertAlmostEqual(cs1.rmsd_to(cs2), 0)
Exemplo n.º 7
0
 def test_elements_closer_than_on_same_line(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 1.]
     cs["s1"] = [0, 0, 2.], [0, 0, 3.]
     self.assertEqual(cs.elements_closer_than(2), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1.01), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1.), [])
     self.assertEqual(cs.elements_closer_than(0.5), [])
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [1, 0, 0.]
     cs["s1"] = [2, 0, 0.], [3, 0, 0.]
     self.assertEqual(cs.elements_closer_than(2), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.5), [])
Exemplo n.º 8
0
 def test_elements_closer_than_parallel_far(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 1.]
     cs["s1"] = [0, 1, 2], [0, 1, 3.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1), [])
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s1"] = [0, 0, 0.], [0, 0, 1.]
     cs["s0"] = [0, 1, 2], [0, 1, 3.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1), [])
Exemplo n.º 9
0
    def test_rmsd_to_is_a_symmetric_relation(self):
        cs1 = LineSegmentStorage(["s0", "m3", "s1", "i0", "s2"])
        cs2 = LineSegmentStorage(["s0", "s1", "s2", "i0", "m3"])

        for r in range(RANDOM_REPETITIONS):
            cs1["s0"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs1["s1"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs1["s2"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs1["i0"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs1["m3"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs2["s0"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs2["s1"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs2["s2"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs2["i0"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            cs2["m3"]=[rand(),rand(),rand()],[rand(),rand(),rand()]
            self.assertAlmostEqual(cs1.rmsd_to(cs2), cs2.rmsd_to(cs1))
Exemplo n.º 10
0
 def test_get_direction(self):
     cs1 = LineSegmentStorage(["s0", "s1", "s2", "s3"])
     cs1["s1"] = [-1, -1, -2], [1, 2, 4]
     nptest.assert_almost_equal(cs1.get_direction("s1"), [2, 3, 6])
Exemplo n.º 11
0
 def test_elements_closer_real_world_example(self):
     cs = LineSegmentStorage(["m0", "m1"])
     cs["m0"] = [0., 0., 1.], [-2.76245752, -6.86976093,  7.54094508]
     cs["m1"] = [-27.57744115,   6.96488989, -
                 22.47619655], [-16.93424799,  -4.0631445, -16.19822301]
     self.assertEqual(cs.elements_closer_than(25), [("m0", "m1")])
Exemplo n.º 12
0
 def test_elements_closer_than_windschief(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 3.]
     cs["s1"] = [1, 1, 3.], [1, -1, -3.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.4), [])
Exemplo n.º 13
0
 def test_elements_closer_than_in_plane(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 3.], [0, 1, 3.]
     cs["s1"] = [1, 0.5, 3.], [2, 0.5, -3.]
     self.assertEqual(cs.elements_closer_than(1.1), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.9), [])
Exemplo n.º 14
0
 def test_elements_closer_than_intersecting(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [-1, -1, -1.], [1, 1, 1.]
     cs["s1"] = [-1, -1, 1.], [1, 1, -1.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.001), [("s0", "s1")])
Exemplo n.º 15
0
 def test_elements_closer_than_parallel_ol(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 1.]
     cs["s1"] = [0, 1, 0.5], [0, 1, 3.]
     self.assertEqual(cs.elements_closer_than(2), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.5), [])
Exemplo n.º 16
0
 def test_elements_closer_than_overlapping(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 1.]
     cs["s1"] = [0, 0, 0.5], [0, 0, 3.]
     self.assertEqual(cs.elements_closer_than(2), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.5), [("s0", "s1")])