示例#1
0
def test_snf_require_non_singular_matrix():
    from pylada.crystal.cutilities import smith_normal_form
    from numpy import array
    from pytest import raises
    from pylada import error
    with raises(error.ValueError):
        smith_normal_form(array([[0, 0, 0], [1, 2, 0], [3, 4, 5]]))
示例#2
0
def test_snf_require_non_singular_matrix():
    from pylada.crystal.cutilities import smith_normal_form
    from numpy import array
    from pytest import raises
    from pylada import error
    with raises(error.ValueError):
        smith_normal_form(array([[0, 0, 0], [1, 2, 0], [3, 4, 5]]))
示例#3
0
def test_smith_normal_form():
    from numpy import dot, all
    from numpy.random import randint
    from numpy.linalg import det
    from pylada.crystal.cutilities import smith_normal_form

    for i in range(50):
        cell = randint(-5, 5, size=(3, 3))
        while abs(det(cell)) < 1e-2:
            cell = randint(-5, 5, size=(3, 3))
        s, l, r = smith_normal_form(cell)
        assert all(dot(dot(l, cell), r) == s)
示例#4
0
def test_smith_normal_form():
    from numpy import dot, all
    from numpy.random import randint
    from numpy.linalg import det
    from pylada.crystal.cutilities import smith_normal_form

    for i in range(50):
        cell = randint(-5, 5, size=(3, 3))
        while abs(det(cell)) < 1e-2:
            cell = randint(-5, 5, size=(3, 3))
        s, l, r = smith_normal_form(cell)
        assert all(dot(dot(l, cell), r) == s)