Fix mypy errors in batch 3 part 1 (#1282)#1368
Conversation
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.
There was a problem hiding this comment.
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.
mhucka
left a comment
There was a problem hiding this comment.
Thanks for doing this. This looks very good.
|
Thank you @mhucka, moving to next part. |
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.