Skip to content

Unexpected behavior of copy_empty_like() for BlueprintCircuits #13535

@ryan-woo

Description

@ryan-woo

Environment

  • Qiskit version: 1.3.0
  • Python version: 3.12.5
  • Operating system: MacOS

What is happening?

QuantumCircuit.copy_empty_like() copies RealAmplitudes instruction to the clone.

How can we reproduce the issue?

>>> from qiskit.circuit.library import RealAmplitudes
>>> circuit = RealAmplitudes(num_qubits=2, reps=2)
>>> circuit.draw()
     ┌────────────────────────────────────────────────┐
q_0: ┤0                                               ├
     │  RealAmplitudes(θ[0],θ[1],θ[2],θ[3],θ[4],θ[5]) │
q_1: ┤1                                               ├
     └────────────────────────────────────────────────┘
>>> circuit.copy_empty_like().draw()
     ┌────────────────────────────────────────────────┐
q_0: ┤0                                               ├
     │  RealAmplitudes(θ[0],θ[1],θ[2],θ[3],θ[4],θ[5]) │
q_1: ┤1                                               ├
     └────────────────────────────────────────────────┘
>>> circuit.copy_empty_like() == circuit
True
>>> 

What should happen?

The copy should not have a gate

Any suggestions?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions