Пример #1
0
def test_VectorParser_explicit():
    vp = displace.VectorParser()
    assert np.allclose(vp('[1., 2., 3.]'), [1, 2, 3])
Пример #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)
Пример #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])
Пример #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)
Пример #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)
Пример #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])
Пример #7
0
def test_VectorParser_xyz_unary():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    assert np.allclose(vp('-1'), -xyz[1])
Пример #8
0
def test_VectorParser_xyz_getter():
    xyz = eg.c2h4[1]
    vp = displace.VectorParser(xyz)
    assert np.allclose(vp.xyz, xyz)
Пример #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))
Пример #10
0
def test_VectorParser_vector():
    vp = displace.VectorParser()
    assert np.allclose(vp([1, 2, 3]), [1, 2, 3])