1 Answers1

0

U1Gate is being replaced by PhaseGate (aka p). If you still want to use u1, replace the import PhaseGate in this example by import U1Gate as PhaseGate:

from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate
circuit = QuantumCircuit(2)
circuit.append(PhaseGate(3.14159).control(1, ctrl_state="0"), [0, 1])
print(circuit)
q_0: ─o─────
      │P(π) 
q_1: ─■─────
            

The method control takes the amount of qubits to control on (in this example, 1) and the ctrl_state. In this case, an anticontrol (aka open control) applies phase rotation on q_1 if the q_0 == 0.

luciano
  • 399
  • 4
  • 13