Coverage for gpaw/test/symmetry/test_fractional_translation_grid_compatibility.py: 100%
15 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
1from gpaw.grid_descriptor import GridDescriptor
2import pytest
3import numpy as np
6def test_symmetrize_fractional_translations():
7 gd = GridDescriptor(N_c=np.array([5, 9, 6]))
8 a_g = gd.empty(10)
9 op_scc = [np.identity(3), -np.identity(3)]
10 ft_sc = np.array([[0, 0, 0], [0.5, 0, 0]])
11 with pytest.raises(ValueError, match=r"^The specified number"):
12 gd.symmetrize(a_g, op_scc, ft_sc)
14 newN_c = gd.get_nearest_compatible_grid(ft_sc)
15 assert np.array_equal(newN_c, np.array([6, 9, 6]))
16 ft2_sc = np.array([[1 / 20, 0, 0], [1 / 30, 1 / 4, 0]])
17 newN_c = gd.get_nearest_compatible_grid(ft2_sc)
18 assert np.array_equal(newN_c, np.array([60, 8, 6]))