Skip to content

Harden _parse_fukui's table-end detection - #125

Merged
galjos merged 1 commit into
mainfrom
harden-fukui-parser
Jul 13, 2026
Merged

Harden _parse_fukui's table-end detection#125
galjos merged 1 commit into
mainfrom
harden-fukui-parser

Conversation

@galjos

@galjos galjos commented Jul 13, 2026

Copy link
Copy Markdown
Member

`_parse_fukui` (added in #123) only checked token count (`len(tokens) != 4`) to detect the end of the `Fukui functions:` table. A code review flagged this as an "acceptable risk" of stdout-scraping, but on a second look it's a cheap fix, not something to just accept.

Verified xtb writes this data *only* to stdout: a clean-directory `--vfukui` run writes no dedicated file for it, only `charges`/`wbo`/`xtbrestart`/`xtbtopo.mol` -- so stdout-scraping itself isn't avoidable. But the end-of-table check can be tightened: a coincidental 4-token line right after the real table (before the blank line that actually ends it) would previously get silently misparsed as a data row.

The fix

Also verify the label matches "digits then letters" (`^(\d+)([A-Za-z]+)$`) and the last 3 tokens parse as floats before accepting a row; either check failing now correctly ends the table instead of raising deep inside a malformed row.

Verification

Two new regression tests reproduce the exact failure mode this fixes (a coincidental 4-token line with a bad label, and one with non-numeric values), plus a test for multi-digit atom indices with multi-letter element symbols (e.g. `14Cl`). Full suite: 421 passed, 10 skipped with a real `xtb` binary. New code fully covered (only remaining gap in the file pre-dates this change). Docs build clean.

Closes #124

xtb writes Fukui data only to stdout (verified: a clean-directory
--vfukui run writes no dedicated file for it), so this parser is
unavoidably stdout-scraping -- but it was only checking token count
to detect the end of the table, so a coincidental 4-token line right
after it would get silently misparsed as a data row. Now also checks
the label matches "digits then letters" and the last 3 tokens parse
as floats before accepting a row.
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.40%. Comparing base (8d532e1) to head (ade75ec).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #125   +/-   ##
=======================================
  Coverage   97.39%   97.40%           
=======================================
  Files          32       32           
  Lines        1995     2001    +6     
=======================================
+ Hits         1943     1949    +6     
  Misses         52       52           
Flag Coverage Δ
unittests 97.40% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@galjos
galjos merged commit 9ac88db into main Jul 13, 2026
5 checks passed
@galjos
galjos deleted the harden-fukui-parser branch July 13, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harden _parse_fukui's table-end detection

1 participant