Enhance INCAR parsing: handle multi-line string and line continuation with backslash, fix handling of ! as comment marker#4518
Merged
shyuep merged 4 commits intomaterialsproject:masterfrom Nov 7, 2025
Conversation
! as comment marker
f511b50 to
8a8eeff
Compare
DanielYang59
commented
Oct 13, 2025
| def test_from_str_multiline_string(self): | ||
| incar_str = r""" | ||
| # Multi-line string with embedded comments | ||
| WANNIER90_WIN = "begin Projections # should NOT be capitalized |
Contributor
Author
There was a problem hiding this comment.
An edge case, currently comments in multi-line string would be removed, I guess this agrees with the behaviour described by vaspwiki:
For comments, VASP ignores any text after a hashtag # or exclamation mark !. Use this to add comments anywhere to the INCAR file.
05ffd06 to
2d33219
Compare
Contributor
Author
|
@esoteric-ephemera can you please review this maybe? I understand using RE would hurt readability but I didn't find a better way other than using a quite complex state machine, also added unit test to cover as much edge cases as I could think of. |
4f47a28 to
537b47f
Compare
Contributor
|
@DanielYang59 sure will try to find some time to! |
bc0885b to
20d30ca
Compare
Member
|
I wish VASP would switch to YAML for INCARs.... I think use of regex is fine. We use it all over Vasp.outputs. |
…ling test enhance incar parsing of backslash and multi-line str, fix ! comment handle fix most issues: multi-line str still doesn't work almost there, one statement in comment should not be parsed guess it's fine to strip multi-line string I guess ;! is not a valid use case, ; is meant to connect to statements oops, looks like comment would be parsed fix test first working version
3c4e178 to
55a982d
Compare
Member
|
Thanks! |
Contributor
Author
|
no problem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhancements:
Fixes
!as comment marker for string tags likePREC = Accurate ! hello: