-
Notifications
You must be signed in to change notification settings - Fork 927
fix(outputs.py): handle missing trailing newline in ICOHPLIST.lobster #4350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LOBSTER 5.1.1 sometimes produces an ICOHPLIST.lobster file without a trailing
newline, which causes the Icohplist parser to miscount bond entries (e.g., 1079 vs. 1080).
This commit updates the file-reading logic in Icohplist.__init__ to use splitlines()
and filters out any blank lines, ensuring that only valid, non-empty lines are parsed.
This change prevents the ValueError ("COHPCAR and ICOHPLIST do not fit together")
and aligns the bond count with COHPCAR.lobster.
Ref: See related issue in lobsterpy (materialsproject#389) for additional context.
Signed-off-by: Ali Hussain Umar Bhatti <[email protected]>
|
Thanks, @alibh95, for raising this fix. Can you please also adapt the failing test in the PR? |
|
Please provide a unittest to check for this issue. Thanks. |
|
Hi @alibh95 , it would be great if you can fix the newly added test that is failing and also adapt the existing failing test to reflect correct number of bonds |
- Strip only trailing blank lines so a missing final newline still works - Compute header length dynamically (skip title and optional spin‐line) - Determine LOBSTER version by column count (6→2.2.1, 8→3.1.1, 9→5.1.0) - Preserve non‐orbitalwise LCFO entries (fixes length mismatch for non-orbitalwise LCFO lists)
|
@shyuep I have added the unittest for this issue. |
|
Thanks! |
LOBSTER 5.1.1 sometimes produces an ICOHPLIST.lobster file without a trailing newline, which causes the Icohplist parser to miscount bond entries (e.g., 1079 vs. 1080). This commit updates the file-reading logic in Icohplist.init to use splitlines() and filters out any blank lines, ensuring that only valid, non-empty lines are parsed. This change prevents the ValueError ("COHPCAR and ICOHPLIST do not fit together") and aligns the bond count with COHPCAR.lobster.
Ref: #4349 and JaGeo/LobsterPy#389
Summary
Major changes:
Checklist
ruff.mypy.duecredit@due.dcitedecorators to reference relevant papers by DOI (example)Tip: Install
pre-commithooks to auto-check types and linting before every commit: