File: test_standard_form.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (17 lines) | stat: -rw-r--r-- 550 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def test_standard_form():
    import numpy as np
    from numpy.testing import assert_allclose
    from ase.cell import Cell


    TOL = 1E-10
    rng = np.random.RandomState(0)

    for i in range(20):
        cell0 = rng.uniform(-1, 1, (3, 3))
        for sign in [-1, 1]:
            cell = Cell(sign * cell0)
            rcell, Q = cell.standard_form()
            assert_allclose(rcell @ Q, cell, atol=TOL)
            assert_allclose(np.linalg.det(rcell), np.linalg.det(cell))
            assert_allclose(rcell.ravel()[[1, 2, 5]], 0, atol=TOL)