BUG: downcasting from complex in `apply_unitary`
See original GitHub issueThe following code to multiply PauliY by the identity incorrectly casts the matrix representation of PauliY into the type of the input state (float):
import cirq
import numpy as np
from cirq import protocols
y0 = cirq.PauliString({cirq.LineQubit(0): cirq.Y})
state = 0.5 * np.eye(2)
args = protocols.ApplyUnitaryArgs(target_tensor=state,
available_buffer=np.zeros_like(state),
axes=(0,))
result = protocols.apply_unitary(y0, args)
gives
>>> print(result)
[[0. 0.]
[0. 0.]]
numpy correctly throws a warning about this casting, but this should really throw an error.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This feels like a case where the code should use the larger type.
From cirq sync: We should throw an error.