def test_distance6(self, setup):
        # Create a 1D chain
        geom = Geometry([0]*3, Atom(1, R=1.), sc=1)
        geom.set_nsc([77, 1, 1])
        d = geom.distance(0)
        assert len(d) == 1
        assert np.allclose(d, [1.])

        # Do twice
        d = geom.distance(R=2)
        assert len(d) == 2
        assert np.allclose(d, [1., 2.])

        # Do all
        d = geom.distance(R=np.inf)
        assert len(d) == 77 // 2
        # Add one due arange not adding the last item
        assert np.allclose(d, range(1, 78 // 2))

        # Create a 2D grid
        geom.set_nsc([3, 3, 1])
        d = geom.distance(R=2, tol=[.4, .3, .2, .1])
        assert len(d) == 2 # 1, sqrt(2)
        # Add one due arange not adding the last item
        assert np.allclose(d, [1, 2 ** .5])

        # Create a 2D grid
        geom.set_nsc([5, 5, 1])
        d = geom.distance(R=2, tol=[.4, .3, .2, .1])
        assert len(d) == 3 # 1, sqrt(2), 2
        # Add one due arange not adding the last item
        assert np.allclose(d, [1, 2 ** .5, 2])
 def test_distance8(self, setup):
     geom = Geometry([0]*3, Atom(1, R=1.), sc=1)
     geom.set_nsc([77, 1, 1])
     d = geom.distance(0, method='min')
     assert len(d) == 1
     d = geom.distance(0, method='median')
     assert len(d) == 1
     d = geom.distance(0, method='mode')
     assert len(d) == 1
예제 #3
0
 def test_distance7(self):
     # Create a 1D chain
     geom = Geometry([0] * 3, Atom(1, R=1.), sc=1)
     geom.set_nsc([77, 1, 1])
     # Try with a short R and a long tolerance list
     d = geom.distance(R=1, tol=np.ones(10) * .5)
     assert_equal(len(d), 1)
     assert_true(np.allclose(d, [1.]))
 def test_distance7(self, setup):
     # Create a 1D chain
     geom = Geometry([0]*3, Atom(1, R=1.), sc=1)
     geom.set_nsc([77, 1, 1])
     # Try with a short R and a long tolerance list
     # We know that the tolerance list prevails, because
     d = geom.distance(R=1, tol=np.ones(10) * .5)
     assert len(d) == 1
     assert np.allclose(d, [1.])
 def test_distance2(self, setup):
     geom = Geometry(setup.g.xyz, Atom[6])
     d = geom.distance(R=1.42, method='unknown_numpy_function')
 def test_distance1(self, setup):
     geom = Geometry(setup.g.xyz, Atom[6])
     # maxR is undefined
     d = geom.distance()
예제 #7
0
 def test_distance2(self, setup):
     geom = Geometry(setup.g.xyz, Atom[6])
     with pytest.raises(ValueError):
         d = geom.distance(R=1.42, method='unknown_numpy_function')
예제 #8
0
 def test_distance1(self, setup):
     geom = Geometry(setup.g.xyz, Atom[6])
     # maxR is undefined
     with pytest.raises(ValueError):
         d = geom.distance()