Skip to content

Fix variable assignment mypy error localization - #287

Open
cariluo wants to merge 6 commits into
mainfrom
fix_variable_assignment_mypy_error_localization
Open

Fix variable assignment mypy error localization#287
cariluo wants to merge 6 commits into
mainfrom
fix_variable_assignment_mypy_error_localization

Conversation

@cariluo

@cariluo cariluo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

This PR addresses issue #283, which is about a mypy error in localization.

  • Remove ignore[assignment] flags
  • rename variables
  • Add helper function to decrease duplicated lines of code

@cariluo cariluo linked an issue Aug 27, 2026 that may be closed by this pull request
@cariluo

cariluo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

I have renamed variables to follow the existing naming convention in the file of adding unr to the names of variables. That being said, it might be more descriptive to separate out alpha and beta? I'm imagining something like

alpha_S_ = multi_dot((C_[0].T, self.S, C_[0]))
beta_S_  = multi_dot((C_[1].T, self.S, C_[1]))

instead of

unr_S_ = [multi_dot((C_[s].T, self.S, C_[s])) for s in [0, 1]]

@cariluo
cariluo marked this pull request as ready for review August 27, 2026 14:23
@cariluo
cariluo requested a review from mscho527 August 27, 2026 14:24
@mscho527

Copy link
Copy Markdown
Member

perhaps _a and _b like lmo_coeff?

@mscho527

Copy link
Copy Markdown
Member

it might be possible to remove # type: ignore[attr-defined] after the renaming

@cariluo

cariluo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

it might be possible to remove # type: ignore[attr-defined] after the renaming

If I remove # type: ignore[attr-defined] I get

src/quemb/molbe/mbe.py:1431: error: "BE" has no attribute "C_a"  [attr-defined]
src/quemb/molbe/mbe.py:1434: error: "BE" has no attribute "C_b"  [attr-defined]
src/quemb/molbe/mbe.py:1437: error: "BE" has no attribute "W_unr"  [attr-defined]
src/quemb/molbe/mbe.py:1437: error: "BE" has no attribute "C_a"  [attr-defined]
src/quemb/molbe/mbe.py:1438: error: "BE" has no attribute "W_unr"  [attr-defined]
src/quemb/molbe/mbe.py:1438: error: "BE" has no attribute "C_b"  [attr-defined]

Would you prefer that I add these attributes to BE __init__() or leave the # type: ignore[attr-defined] flags?

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.

Fix variable assignment mypy error in localization

2 participants