File: test_classification_engine.py

package info (click to toggle)
python-ase 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,344 kB
  • sloc: python: 126,379; xml: 946; makefile: 111; javascript: 47
file content (45 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pytest
import numpy as np
from ase.geometry.bravais_type_engine import generate_niggli_op_table


ref_info = {
    'FCC': 1,
    'BCC': 1,
    'CUB': 1,
    'TET': 2,
    'BCT': 5,
    'HEX': 2,
    'ORC': 1,
    'ORCC': 5,
    'ORCF': 2,
    'ORCI': 4,
    'RHL': 3,
    #'MCL': 15,
    #'MCLC': 27,
    #'TRI': 19,
}


# We disable the three lattices that have infinite reductions.
# Maybe we can test those, but not today.
assert len(ref_info) == 14 - 3


def ref_info_iter():
    for key, val in ref_info.items():
        yield key, val


@pytest.mark.parametrize('lattice_name,ref_nops', ref_info_iter())
def test_generate_niggli_table(lattice_name, ref_nops):
    length_grid = np.logspace(-1, 1, 60)
    angle_grid = np.linspace(30, 120, 90 + 59)
    table = generate_niggli_op_table(lattices=[lattice_name],
                                     angle_grid=angle_grid,
                                     length_grid=length_grid)
    for key in table:
        print('{}: {}'.format(key, len(table[key])))

    mappings = table[lattice_name]
    assert len(mappings) == ref_nops