qrisp.QuantumCircuit.bind_parameters#

QuantumCircuit.bind_parameters(subs_dic)[source]#

Returns a QuantumCircuit where the abstract parameters in subs_dic are bound to their specified values.

Parameters
subs_dicdict

A dictionary containing the abstract parameters of this QuantumCircuit as keys and the desired parameters as values.

Returns
QuantumCircuit

The QuantumCircuit with substituted parameters.

Raises
Exception

subs_dic did not specify a value for all abstract parameters.

Examples

We create a QuantumCircuit with some abstract parameters and bind them subsequently:

>>> from qrisp import QuantumCircuit
>>> from sympy import symbols
>>> qc = QuantumCircuit(3)

Create some sympy symbols and use them as abstract parameters for phase gates:

>>> abstract_parameters = symbols("a b c")
>>> for i in range(3): qc.p(abstract_parameters[i], i)

Create the substitution dictionary and bind the parameters:

>>> subs_dic = {abstract_parameters[i] : i for i in range(3)}
>>> bound_qc = qc.bind_parameters(subs_dic)
>>> print(bound_qc)
      ┌──────┐
qb_0: ┤ P(0) ├
      ├──────┤
qb_1: ┤ P(1) ├
      ├──────┤
qb_2: ┤ P(2) ├
      └──────┘