Coverage for gpaw/test/fileio/test_file_reference.py: 100%

11 statements  

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

1"""Test the reading of wave functions as file references.""" 

2import numpy as np 

3from gpaw import GPAW 

4from gpaw.mpi import rank, world 

5 

6 

7def test_fileio_file_reference(in_tmp_dir, gpw_files): 

8 # load restart from gpw 

9 calc = GPAW(gpw_files['na3_fd_kp_restart']) 

10 wf0 = calc.get_pseudo_wave_function(2, 1, 1) 

11 

12 # Now read with a single process 

13 comm = world.new_communicator(np.array((rank,))) 

14 calc = GPAW(gpw_files['na3_fd_kp_restart'], communicator=comm) 

15 wf1 = calc.get_pseudo_wave_function(2, 1, 1) 

16 

17 # compare wf restarts match 

18 diff = np.abs(wf0 - wf1) 

19 assert np.all(diff < 1e-12)