Skip to content

Fix mypy errors in batch 3 part 1 (#1282)#1368

Open
rosspeili wants to merge 3 commits into
quantumlib:mainfrom
rosspeili:fix/issue-1282-mypy-batch3-part1
Open

Fix mypy errors in batch 3 part 1 (#1282)#1368
rosspeili wants to merge 3 commits into
quantumlib:mainfrom
rosspeili:fix/issue-1282-mypy-batch3-part1

Conversation

@rosspeili

Copy link
Copy Markdown
Contributor

Annotate Tensor optional fields and add guards in _namedtensor. Default beta in compute_thc_resources when None (same pattern as DF). Return empty FermionOperator when plane_wave external potential has no terms.

Annotate Tensor optional fields and add guards in _namedtensor. Default beta in compute_thc_resources when None (same pattern as DF). Return empty FermionOperator when plane_wave external potential has no terms.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several type safety improvements, bug fixes, and resource estimation updates. In _namedtensor.py, type annotations were added to the Tensor class, and safety checks were introduced to raise TypeError when required attributes are missing. The vectorize method was also updated to use Literal types and direct array reshaping. In plane_wave_hamiltonian.py, a fallback was added to return an empty FermionOperator if the operator is None. Lastly, in compute_thc_resources.py, a fallback calculation for beta was implemented when it is not provided, and float division was replaced with integer division. There are no review comments, so we have no feedback to provide.

@rosspeili

Copy link
Copy Markdown
Contributor Author

@mhucka I moved to batch 3 from #1282, this PR fixes strict-mypy issues in _namedtensor, compute_thc_resources (default beta when None, same as DF), and a plane_wave_hamiltonian return narrowing leftover from #1365. Let me know how this looks and can move to next part.

@mhucka mhucka added the priority/before-1.7.2 Things to do before the next release label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/before-1.7.2 Things to do before the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants