-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
SparsePauliOp casting of coeffs causes errors for dtype=real #8992
Labels
bug
Something isn't working
Comments
Yeah, seems like the allowed dtypes here should only be @ikkoham: did you have more dtypes in mind when you wrote that part of the handling? |
Ever wanted to use a float to save data? Well, no. |
OK, I'll restrict it to complex and object. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
What is happening?
The current init for
SparsePauliOp
has handling for storing coefficient arrays using their input dtype, but this is used to cast the coeffs to that type after moving the Pauli phase to the coeffs. This can cause errors if the dtype is not complex.How can we reproduce the issue?
Here is an example which gives an incorrect answer:
This raises a warning
and returns the incorrect value
What should happen?
For the above example the correct answer should be
Any suggestions?
Removing the explicit dype in the line from the warning should fix this, which would allow double coeffs to be converted to complex if required.
I suspect this support was added in the first place to handle object arrays for parameters, and I think that should still be supported if the dtype arg is not used since the asarray should default to an object array in that case.
The text was updated successfully, but these errors were encountered: