Ejemplo n.º 1
0
def test_VectorParser_explicit():
    vp = displace.VectorParser()
    assert np.allclose(vp('[1., 2., 3.]'), [1, 2, 3])
Ejemplo n.º 2
0
def test_VectorParser_xyz_mixed():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    soln = [1.2, xyz[3, 0]**2, np.dot(xyz[3], xyz[2] - xyz[1])]
    assert np.allclose(vp('[1.2, 3[0]^2., 3 o (2 - 1)]'), soln)
Ejemplo n.º 3
0
def test_VectorParser_unrec_axis():
    vp = displace.VectorParser()
    with pytest.raises(ValueError, match=r'Axis specification not recognized'):
        rot = vp([1, 1, 1, 1])
Ejemplo n.º 4
0
def test_VectorParser_xyz_cross():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    soln = np.cross(xyz[3] - xyz[1], xyz[4] - xyz[1])
    assert np.allclose(vp('(3 - 1) x (4 - 1)'), soln)
Ejemplo n.º 5
0
def test_VectorParser_xyz_proj():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    soln = np.dot(xyz[3], xyz[1]) / np.dot(xyz[1], xyz[1]) * xyz[1]
    assert np.allclose(vp('(3 o 1) / (1 o 1) * 1'), soln)
Ejemplo n.º 6
0
def test_VectorParser_xyz_subtract():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    assert np.allclose(vp('3 - 1'), xyz[3] - xyz[1])
Ejemplo n.º 7
0
def test_VectorParser_xyz_unary():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    assert np.allclose(vp('-1'), -xyz[1])
Ejemplo n.º 8
0
def test_VectorParser_xyz_getter():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    assert np.allclose(vp.xyz, xyz)
Ejemplo n.º 9
0
def test_VectorParser_cross_unit():
    vp = displace.VectorParser()
    ax = np.array([[6, -3, 2], [1, 1, 1], [2, 2, 0]])
    ax2 = np.array([1, 2, 3])
    assert np.allclose(vp(ax, unit=True), ax2 / np.linalg.norm(ax2))
Ejemplo n.º 10
0
def test_VectorParser_vector():
    vp = displace.VectorParser()
    assert np.allclose(vp([1, 2, 3]), [1, 2, 3])