pyquil
pyquil copied to clipboard
Defgate matrices should be type np.complex_
Pre-Report Checklist
- [ ] I am running the latest versions of pyQuil and the Forest SDK
- [ ] I checked to make sure that this bug has not already been reported
Issue Description
Matrices in DefGates contain complex
numbers, but they are stored as objects rather than np.complex128
(or better yet np.complex256
). This causes some common numpy operations such as np.real
to fail.
How to Reproduce
import numpy as np
from pyquil.quilbase import DefGate
theta, phi = rng.random(2)*2*np.pi
defgate = DefGate(f"FSIM_{theta_deg}_{phi_deg}", matrix=matrices.FSIM(theta, phi))
defgate.matrix