File: test_resolve_custom_kpoints.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 (40 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download | duplicates (2)
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
import pytest
import numpy as np
from ase.dft.kpoints import resolve_custom_points


@pytest.fixture
def special_points():
    return dict(A=np.zeros(3),
                B=np.ones(3))


def test_str(special_points):
    path, dct = resolve_custom_points('AB', special_points, 0)
    assert path == 'AB'
    assert set(dct) == set('AB')


def test_recognize_points_from_coords(special_points):
    path, dct = resolve_custom_points(
        [[special_points['A'], special_points['B']]], special_points, 1e-5)
    assert path == 'AB'
    assert set(dct) == set('AB')


@pytest.mark.parametrize(
    'kptcoords',
    [
        [np.zeros(3), np.ones(3)],
        [[np.zeros(3), np.ones(3)]],
    ]
)
def test_autolabel_points_from_coords(kptcoords, special_points):
    path, dct = resolve_custom_points(kptcoords, {}, 0)
    assert path == 'Kpt0Kpt1'
    assert set(dct) == {'Kpt0', 'Kpt1'}  # automatically labelled


def test_bad_shape():
    with pytest.raises(ValueError):
        resolve_custom_points([[np.zeros(2)]], {}, 0)