Coverage for gpaw/test/utilities/test_varing_fold.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-08 00:17 +0000

1import numpy as np 

2import pytest 

3 

4from gpaw.utilities.folder import Folder 

5 

6 

7def test_vering_fold(): 

8 x = [1, 3, 5, 7, 9] 

9 y = [2, 6, 1, 9, 3] 

10 

11 width = 0.2 

12 width2 = 0.4 

13 x1 = 4 

14 x2 = 8 

15 for folding in ['Gauss', 'Lorentz']: 

16 x_c, y_c = Folder(width, folding).fold(x, y) 

17 

18 x_v, y_v = Folder(width, folding).varing_fold(x, y, 

19 width2=width2, 

20 x1=x1, x2=x2) 

21 assert (x_c == x_v).all() 

22 

23 i = np.where(x_c < 4) 

24 assert y_c[i] == pytest.approx(y_v[i], abs=1e-01) 

25 

26 i2 = np.where(x_c > 8) 

27 assert max(y_c[i2]) > max(y_v[i2])