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

Fixed bug on parsing coordinates of WFs when there is no space #21

Merged
merged 2 commits into from
Feb 5, 2018

Conversation

giovannipizzi
Copy link
Member

after the comma (for many-digit numbers). Not perfect,
but good workaround (also for #1) that does not require to change
Wannier90.

after the comma (for many-digit numbers). Not perfect,
but good workaround (also for #1) that does not require to change
Wannier90.
@giovannipizzi
Copy link
Member Author

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()
Copy link
Member

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.

Copy link
Member Author

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()
)
Copy link
Member

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?

Copy link
Member Author

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

@giovannipizzi giovannipizzi merged commit 342fad8 into master Feb 5, 2018
@giovannipizzi giovannipizzi deleted the fix_parser_bug_positions branch February 5, 2018 08:37
@giovannipizzi
Copy link
Member Author

Just to avoid to forget, I write it here: a fast way to try the parser is

from aiida.parsers import ParserFactory
WP = ParserFactory('wannier90.wannier90')
wp = WP(calculation=load_node(24302))
wp.parse_from_calc()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants