Skip to content
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

fix: Add missing comma in LHEInit fieldnames #282

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pylhe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _indent(elem, level=0):
class LHEInit(dict):
"""Store the <init> block as dict."""

fieldnames = ["initInfo", "procInfo" "weightgroup", "LHEVersion"]
fieldnames = ["initInfo", "procInfo", "weightgroup", "LHEVersion"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fieldnames = ["initInfo", "procInfo", "weightgroup", "LHEVersion"]

If we don't explicitly use

fieldnames = ["initInfo", "procInfo" "weightgroup", "LHEVersion"]

then should we keep them at all?

Given that this line was never getting used (else we would have seen this non-list list break) I think we can just remove this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at the module. Most other classes have a fromstring method, which uses fieldnames. This one LHEInit doesn't. I'm no expert to understand why. Would it be useful to add such a method?

In any case, one thing the variable fieldnames is good for is documentation. Right now the docstring is minimalistic and maybe that's worth a revamp as well?

Copy link
Member

@APN-Pucky APN-Pucky Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most other classes have a fromstring method, which uses fieldnames. This one LHEInit doesn't. I'm no expert to understand why. Would it be useful to add such a method?

I would be in favor of adding a fromstring there too. It sort of exists as part of read_lhe_init(file_or_string) function, but that can then be mapped to use the new fromstring.

The test on the fieldnames values would then just be if tolhe(fromstring(...)) and fromstring(tolhe(...)) are consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a PR to add fromstring #283, but just like the read_lhe_init it does not use fieldnames and I don't see the point in forcing it to use it now.


def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
Loading