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

Improve Bandoverlaps parser #3689

Merged

Conversation

naik-aakash
Copy link
Contributor

Issue

Current implementation of Bandoverlaps parser adds keys with '.' in band_overlaps_dict attribute leading to failure of pydantic checks in atomate2 lobster workflow materialsproject/atomate2#769

Changes

  1. Rewrite output format of band_overlaps_dict attribute of Bandoverlaps class
  2. Update and add associated tests

overlaps.append(float(el))
self.band_overlaps_dict[spin][" ".join(kpoint_array)]["matrix"].append(overlaps)
rows += [float(el)]
overlaps += [rows]
Copy link
Member

Choose a reason for hiding this comment

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

overlaps is possibly unbound now from renaming overlaps = [] to rows above.

we don't check for this in CI yet due to way too many legacy violations but really should. related discussion in #3646

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @janosh, I did not get what you meant here. Can you please elaborate a bit more? I need the overlaps variable initialized in the previous if clause to properly store matrices for each k-point.

Is there anything I need to do ? I could not think of any other way to do this.

Copy link
Member

Choose a reason for hiding this comment

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

the problem is, if the code enters the else case overlaps won't be declared, so Python will throw a NameError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, such case won't happen as per the current file format, it will always pass through the elif clause .

But I Will check for a few more examples that I have and see If I encounter any errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @janosh , I checked for about 20 different example files which I have, does not result in NameError due to file format , logic seems to work without breaking it 😃

But if you have any better idea to get same outcome, I am happy to implement it. Just at this point I seem to have blanked out 😅 and cannot think of any alternatives

Copy link
Member

Choose a reason for hiding this comment

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

you could pip install pyright and run it on this file. it'll show you the error i mean. you just need to ensure overlaps is declared by all code paths

Copy link
Contributor Author

@naik-aakash naik-aakash Mar 15, 2024

Choose a reason for hiding this comment

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

Hi @janosh , I have now addressed the errors which I could using pyright. If you think these are okay it could be merged.

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

thanks @naik-aakash! 👍

@janosh janosh added io Input/output functionality fix Bug fix PRs lobster Lobster package (Local Orbital Basis Suite Towards Electronic-Structure Reconstruction) labels Mar 15, 2024
@janosh janosh merged commit df3d7bf into materialsproject:master Mar 15, 2024
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix PRs io Input/output functionality lobster Lobster package (Local Orbital Basis Suite Towards Electronic-Structure Reconstruction)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants