-
Notifications
You must be signed in to change notification settings - Fork 921
Description
Python version
Python 3.12.7
Pymatgen version
2025.3.10
Operating system version
Ubuntu 24.04.2 LTS
Current behavior
When using LOBSTER version 5.1.1, the generated ICOHPLIST.lobster file may not include a trailing newline. This causes the Icohplist parser in pymatgen’s outputs module to miscount the number of bond entries. For example, ICOHPLIST.lobster is parsed with 1079 entries, while COHPCAR.lobster contains 1080 bonds. This mismatch triggers a ValueError:
ValueError: COHPCAR and ICOHPLIST do not fit together
Expected Behavior
The parser should correctly count the bond entries even if ICOHPLIST.lobster lacks a trailing newline. For instance, by using Python’s splitlines() method (which automatically handles missing trailing newlines) and filtering out any empty lines, the bond count should accurately reflect the intended number of bonds, allowing the analysis to proceed without error.
Minimal example
Relevant files to reproduce this bug
Steps to reproduce the behavior:
-
Generate LOBSTER output files (ICOHPLIST.lobster and COHPCAR.lobster) using LOBSTER version 5.1.1.
-
Verify that ICOHPLIST.lobster does not end with a trailing newline (e.g., by opening the file in a text editor or running:
wc -l ICOHPLIST.lobster
grep -n "." ICOHPLIST.lobster
to compare the line counts).
-
Run a pymatgen-based workflow (or a LobsterPy/pymatgen script) that reads these files.
-
The parser miscounts the bonds and raises the ValueError.