-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,14 +208,27 @@ def raw_wout_parser(wann_out_file): | |
wf_out_i['wannier_function'] = int( | ||
line.split('(')[0].split()[-1] | ||
) | ||
wf_out_i['spread'] = float(line.split('(')[1].split()[-1]) | ||
wf_out_i['spread'] = float(line.split(')')[1].strip()) | ||
#wf_out_i['spread'] = float(line.split()[-1]) | ||
#x = float(line.split()[-5].strip(',')) | ||
#y = float(line.split()[-4].strip(',')) | ||
#z = float(line.split()[-3].strip(',')) | ||
x = float(line.split('(')[1].split()[0].strip(',')) | ||
y = float(line.split('(')[1].split()[1].strip(',')) | ||
z = float(line.split('(')[1].split()[2].strip(',')) | ||
try: | ||
x = float( | ||
line.split('(')[1].split(')')[0].split(',')[0].strip() | ||
) | ||
except (ValueError, IndexError): | ||
# To avoid that the crasher completely fails, we set None as a fallback | ||
x = None | ||
try: | ||
y = float( | ||
line.split('(')[1].split(')')[0].split(',')[1].strip() | ||
) | ||
except (ValueError, IndexError): | ||
y = None | ||
try: | ||
z = float( | ||
line.split('(')[1].split(')')[0].split(',')[2].strip() | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could de-duplicate the Maybe something like the following?
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 commentThe 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 |
||
except (ValueError, IndexError): | ||
z = None | ||
coord = (x, y, z) | ||
wf_out_i['coordinates'] = coord | ||
wf_out.append(wf_out_i) | ||
|
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 thefloat
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 :-)