-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fixed bug on parsing coordinates of WFs when there is no space #21
Conversation
after the comma (for many-digit numbers). Not perfect, but good workaround (also for #1) that does not require to change Wannier90.
Feel free to delete the fix_ branch after merging |
z = float(line.split('(')[1].split()[2].strip(',')) | ||
try: | ||
x = float( | ||
line.split('(')[1].split(')')[0].split(',')[0].strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the final .strip()
actually necessary? I think the float
constructor is happy to accept string with leading or trailing whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably right, I wanted to be sure :-)
try: | ||
z = float( | ||
line.split('(')[1].split(')')[0].split(',')[2].strip() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could de-duplicate the line.split('(')[1].split(')')[0].split(',')
part:
Maybe something like the following?
x, y, z = (
float(val) for val in
line.split('(')[1].split(')')[0].split(',')
)
Or is there a case where one of the coordinates could fail, but not the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is unfortunately, when ******* is printed. We will need anyway at some point to change Wannier90 to print what we need in a csv file or similar as discussed in #1
Just to avoid to forget, I write it here: a fast way to try the parser is
|
after the comma (for many-digit numbers). Not perfect,
but good workaround (also for #1) that does not require to change
Wannier90.