diff --git a/electronicparsers/cp2k/parser.py b/electronicparsers/cp2k/parser.py index 236f86a1..47bfb2ac 100644 --- a/electronicparsers/cp2k/parser.py +++ b/electronicparsers/cp2k/parser.py @@ -1570,24 +1570,23 @@ def parse(name, data, section): input_files = get_files( input_filename, self.filepath, self.mainfile, deep=False ) - if not input_files: - self.logger.warning( - 'Input *.inp file not found. We will attempt finding the restart file from ' - 'the project_name appending a -1, -1.restart.', - data={'project_name': project_name}, - ) - # Patch to check if the input is .restart and CP2K appended a -1 after the name + if not input_files: # ? what is the purpose of this recovery logic + self.logger.warning('Input (*.inp) file not found.') if project_name: project_filename = f'{project_name}-1.restart' + self.logger.warning( + f'Will attempt from restart file ({project_filename})' + ) input_files = get_files( project_filename, self.filepath, self.mainfile, deep=False ) - else: - return - if len(input_files) > 1: + if len(input_files) == 0: + return + elif len(input_files) > 1: self.logger.warning( - f'Multiple input files found. We will parse the first read file.' - ) + f'Multiple input files found. Will parse the first file retrieved.' + ) # ! TODO: employ better heuristic OR parse all + # cover single or multiple `input_files` self.inp_parser.mainfile = input_files[0] parse('x_cp2k_section_input', self.inp_parser.tree, self.archive.run[-1]) diff --git a/electronicparsers/wien2k/parser.py b/electronicparsers/wien2k/parser.py index daada6ee..9a1e8b34 100644 --- a/electronicparsers/wien2k/parser.py +++ b/electronicparsers/wien2k/parser.py @@ -1127,18 +1127,20 @@ def parse_method(self): atom_obj = AtomParameters() atom_obj.atom_index = atom_index atom_obj.core_hole = CoreHole( - j_quantum_number = j_quantum_number, - l_quantum_number = l_quantum_number, - n_quantum_number = n_quantum_number, - n_electrons_excited = electrons_excited, - occupation = occupancy, - dscf_state = 'final', + j_quantum_number=j_quantum_number, + l_quantum_number=l_quantum_number, + n_quantum_number=n_quantum_number, + n_electrons_excited=electrons_excited, + occupation=occupancy, + dscf_state='final', ) atom_par.append(atom_obj) break else: - self.logger.warning("inc file is missing, no corehole information " - "will be parsed if corehole present.") + self.logger.warning( + 'inc file is missing, no corehole information ' + 'will be parsed if corehole present.' + ) # basis if self.in1_parser.mainfile: self.in1_parser.parse() diff --git a/tests/test_wien2kparser.py b/tests/test_wien2kparser.py index ba05d7b1..fb20ba0b 100644 --- a/tests/test_wien2kparser.py +++ b/tests/test_wien2kparser.py @@ -26,6 +26,7 @@ CoreHole, ) + def approx(value, abs=0, rel=1e-6): return pytest.approx(value, abs=abs, rel=rel) @@ -125,6 +126,7 @@ def test_dos(parser, caplog): 2.7395685667470246e17 ) + def test_core_hole(parser, caplog): archive = EntryArchive() parser.parse('tests/data/wien2k/TiN-corehole/TiN-corehole.scf', archive, None)