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

Exception with np.ndarray transpose because it's not row major #22

Open
jamesETsmith opened this issue Sep 13, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@jamesETsmith
Copy link
Contributor

General

np.transpose() and the .T operator often (always in the case of .T) return views of the transposed array. Since it's not actually transposed, it's not row major in memory and will lead to a runtime error on the C++ side.

Details

For now we suggest, copying after the transpose to actually produce row major ordering.

op = fp.PauliOp(...)
psi = np.random.rand(7, 64) # (n_states, dim)
op.apply(psi.T) # fails
op.apply(psi.T.copy()) # succeeds
@jamesETsmith jamesETsmith added the bug Something isn't working label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant