Pre-Report Checklist
- [ X] I am running the latest versions of pyQuil and the Forest SDK
- [ X] I checked to make sure that this bug has not already been reported
Issue Description
When a DefGate without parameters is constructed, the user-specified matrix is numerically checked to determine if it is unitary.
If the matrix contains Expressions having only numeric arguments (i.e. no Parameters), the numeric check will be run and subsequently fail due to the presence of the non-numeric Expressions.
Code Snippet
import numpy as np
from pyquil.quilatom import quil_sin
from pyquil.quilbase import DefGate
unitary = np.array(
[
[quil_sin(1.23), 0],
[0, 0],
]
)
gate_def = DefGate("MY_GATE", unitary)
Error Output
Traceback (most recent call last):
File "test.py", line 12, in <module>
gate_def = DefGate("MY_GATE", unitary)
File "...site-packages/pyquil/quilbase.py", line 437, in __init__
is_unitary = np.allclose(np.eye(rows), self.matrix.dot(self.matrix.T.conj()))
TypeError: loop of ufunc does not support argument 0 of type Function which has no callable conjugate method
Environment Context
pyQuil: 4.0.3 (issue also occurs under 3.5.4)
Operating System: Fedora 38
Python Version (python -V): 3.9.9
Pre-Report Checklist
Issue Description
When a
DefGatewithout parameters is constructed, the user-specified matrix is numerically checked to determine if it is unitary.If the matrix contains
Expressions having only numeric arguments (i.e. noParameters), the numeric check will be run and subsequently fail due to the presence of the non-numericExpressions.Code Snippet
Error Output
Environment Context
pyQuil: 4.0.3 (issue also occurs under 3.5.4)
Operating System: Fedora 38
Python Version (python -V): 3.9.9