Closed SimoneGasperini closed 11 months ago
Thanks for this report. I poked into the code a little bit, and it turns out that eventually this is reduces to the bug reported by #7326, because RGate
gets controlled into something containing a CUGate
. That said, we could potentially have headed that off by having an __array__
method defined on ControlledGate
, but I'm not fully convinced that that's a good idea, since we don't require that general Gate
instances have an __array__
method, so it's not clear how it should work well.
Fixing CUGate
's bad behaviour around parameters would be the cleanest way to cause this to work. PR #9118 should do that, which I need to revisit.
Environment
What is happening?
The
quantum_info.Operator
constructor fails because of an unbound parameter while all the free parameters of the circuit seem to be properly bound.How can we reproduce the issue?
TypeError: ParameterExpression with unbound parameters ({ParameterVectorElement(x[0])}) cannot be cast to a float.
What should happen?
The code above should work correctly. For other very similar parameterized quantum circuit (see the
pqc
instance defined below), it runs as expected without any problem.Any suggestions?
I actually have no idea about why this is happening but it looks like a problem only related to controlled-gates with more than one parameter (e.g. CRGate, CUGate).