From a3cad5508ee8b61129e940db2101ef4aeedf9a9a Mon Sep 17 00:00:00 2001 From: bastonero Date: Tue, 13 Feb 2024 13:22:07 +0000 Subject: [PATCH] HpParser: fix q-points/atoms output test case The current raw output parser would miss some corner cases, when lots of q-points are generated and the number has no more any space left from the parenthesis. The solution is to use a more general regex search. As a sanity check, also the perturbed atom number sites regex search is changed correspondingly. --- src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py | 4 ++-- .../hp/initialization_only_mesh_more_points/aiida.out | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py b/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py index 5041839..96b5a4e 100644 --- a/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py +++ b/src/aiida_quantumespresso_hp/parsers/parse_raw/hp.py @@ -31,13 +31,13 @@ def parse_raw_output(stdout): detect_important_message(logs, line) # A calculation that will only perturb a single atom will only print one line - match = re.search(r'.*The grid of q-points.*\s+([0-9]+)+\s+q-points.*', line) + match = re.search(r'.*The grid of q-points.*?(\d+)+\s+q-points.*', line) if match: parsed_data['number_of_qpoints'] = int(match.group(1)) # Determine the atomic sites that will be perturbed, or that the calculation expects # to have been calculated when post-processing the final matrices - match = re.search(r'.*List of\s+([0-9]+)\s+atoms which will be perturbed.*', line) + match = re.search(r'.*List of.*?(\d+)\s+atoms which will be perturbed.*', line) if match: hubbard_sites = {} number_of_perturbed_atoms = int(match.group(1)) diff --git a/tests/parsers/fixtures/hp/initialization_only_mesh_more_points/aiida.out b/tests/parsers/fixtures/hp/initialization_only_mesh_more_points/aiida.out index a5b4b02..dc3e095 100644 --- a/tests/parsers/fixtures/hp/initialization_only_mesh_more_points/aiida.out +++ b/tests/parsers/fixtures/hp/initialization_only_mesh_more_points/aiida.out @@ -167,7 +167,7 @@ Changing the type of the perturbed atom back to its original type... - The grid of q-points ( 4, 4, 4) ( 18 q-points ) : + The grid of q-points ( 4, 4, 4) (18 q-points ) : N xq(1) xq(2) xq(3) wq 1 0.000000000 0.000000000 0.000000000 0.015625000 2 0.000000000 0.216131358 -0.211002628 0.062500000