Coverage for gpaw/test/hyperfine/test_hyperfine_cli.py: 100%
21 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-19 00:19 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-19 00:19 +0000
1"""Test hyperfine parameter CLI."""
2import pytest
3import numpy as np
5from gpaw.hyperfine import main
8@pytest.mark.parametrize('option', ['', '-x', '-d'])
9@pytest.mark.serial
10def test_hyperfine_cli(gpw_files, capsys, option):
11 file = gpw_files['o2_pw']
12 main(f'{file} -g O:-0.757 -u MHz {option}'.split())
13 out = capsys.readouterr().out
14 print(out)
15 lines = [line.split() for line in out.splitlines()]
16 if option == '-x':
17 ref = [0.689, 33.74, -246.58, -246.58, 0.0, 0.0, 0.0]
18 elif option == '-d':
19 ref = [0.689, -78.01, -78.01, 202.31]
20 else:
21 ref = [0.689, 202.31, -78.01, -78.01, 0.0, 0.0, 0.0]
22 for line in lines[3:5]:
23 errors = (np.array([float(x) for x in line[2:]]) - ref)
24 assert abs(errors).max() < 0.2
25 assert float(lines[7][3]) == 2.0
26 assert float(lines[10][1]) == -0.757