Skip to content

Parameter cache is preserved after copy_empty_like #12617

@nkanazawa1989

Description

@nkanazawa1989

Environment

  • Qiskit version: main
  • Python version:
  • Operating system:

What is happening?

Parameter appears in empty circuit after copy

How can we reproduce the issue?

p1 = Parameter("P1")
qc = QuantumCircuit(1)
qc.rz(p1, 0)
qc.parameters  # dummy call to fill cache

cpy = qc.copy_empty_like()
cpy.parameters

I see

ParameterView([Parameter(P1)])

which should not exist.

What should happen?

Parameter should be empty

Any suggestions?

Nullify _parameters after copy

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions