diff --git a/CHANGELOG.md b/CHANGELOG.md index ee2731a..bbe4f76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [unreleased] +### Fixed +- Deleted ORCA `parse_natoms` to fix parsing of xTB log files. +- Fixed gradient regex to account for arbitrary number of stars in log file. + + ## [0.10.1] - 2026-05-02 ### Fixed diff --git a/src/qccodec/parsers/orca.py b/src/qccodec/parsers/orca.py index 373f5f8..e670cfa 100644 --- a/src/qccodec/parsers/orca.py +++ b/src/qccodec/parsers/orca.py @@ -147,7 +147,9 @@ def parse_hessian(contents: str) -> list[list[float]]: for block in blocks: lines = block.splitlines() if not len(lines) == dim: - raise ParserError(f"Block line count {len(lines)} does not match dimension {dim}: {block}") + raise ParserError( + f"Block line count {len(lines)} does not match dimension {dim}: {block}" + ) for i, line in enumerate(block.splitlines()): row = list(map(float, line.split()[1:])) @@ -194,9 +196,10 @@ def parse_trajectory( # Capture the stdout for each gradient calculation regex = ( - r"GEOMETRY\s*OPTIMIZATION\s*CYCLE\s*\d+\s*\*\s*\n\s*\**\s*\n" # header - r"(.*?)" # body - r"-*\s*\n\s*ORCA\s+GEOMETRY\s+RELAXATION\s+STEP" + r"GEOMETRY\s*OPTIMIZATION\s*CYCLE\s*\d+.*?" # Match cycle line + r"\*+\n" # Match the line of stars + r"(.*?)" # Body (Captured) + r"-+\s*\n\s*ORCA\s+GEOMETRY\s+RELAXATION\s+STEP" # Footer ) per_gradient_stdout = re.findall(regex, stdout, flags=re.DOTALL) if not per_gradient_stdout: @@ -249,21 +252,6 @@ def parse_version(contents: str) -> str: return match.group(1) -@register(filetype=OrcaFileType.STDOUT, target="calcinfo_natoms") -def parse_natoms(contents: str) -> int: - """Parse number of atoms value from Orca stdout. - - Returns: - The number of atoms as an integer. - - Raises: - MatchNotFoundError: If the regex does not match. - """ - regex = r"Number of atoms\s*...\s*(\d+)" - match = re_search(regex, contents) - return int(match.group(1)) - - def parse_basename(contents: str) -> str: """Parse the file basename from Orca stdout.""" regex = r"NAME\s+=\s+(.*)" diff --git a/tests/data/orca/answers/trajectory.json b/tests/data/orca/answers/trajectory.json index adb2424..f479222 100644 --- a/tests/data/orca/answers/trajectory.json +++ b/tests/data/orca/answers/trajectory.json @@ -69,7 +69,7 @@ }, "success": true, "data": { - "calcinfo_natoms": 3, + "calcinfo_natoms": null, "calcinfo_nalpha": null, "calcinfo_nbeta": null, "calcinfo_nbasis": null, @@ -187,7 +187,7 @@ }, "success": true, "data": { - "calcinfo_natoms": 3, + "calcinfo_natoms": null, "calcinfo_nalpha": null, "calcinfo_nbeta": null, "calcinfo_nbasis": null, @@ -305,7 +305,7 @@ }, "success": true, "data": { - "calcinfo_natoms": 3, + "calcinfo_natoms": null, "calcinfo_nalpha": null, "calcinfo_nbeta": null, "calcinfo_nbasis": null, @@ -423,7 +423,7 @@ }, "success": true, "data": { - "calcinfo_natoms": 3, + "calcinfo_natoms": null, "calcinfo_nalpha": null, "calcinfo_nbeta": null, "calcinfo_nbasis": null, @@ -471,4 +471,4 @@ "hostmem": null } } -] \ No newline at end of file +] diff --git a/tests/test_orca_parsers.py b/tests/test_orca_parsers.py index 78deddb..980ec8e 100644 --- a/tests/test_orca_parsers.py +++ b/tests/test_orca_parsers.py @@ -7,7 +7,6 @@ parse_energy, parse_gradient, parse_hessian, - parse_natoms, parse_trajectory, parse_version, ) @@ -87,14 +86,6 @@ answer=hessians.water_revdsd, extra_files=["water.numhess.hess"], ), - ParserTestCase( - name="Parse number of atoms water", - parser=parse_natoms, - stdout=Path("water.energy.out"), - calctype=CalcType.energy, - success=True, - answer=3, - ), ParserTestCase( name="Parse trajectory", parser=parse_trajectory,