Skip to content

qpy doesn't percolate delay gate's units #10662

@vtomole

Description

@vtomole

Environment

  • Qiskit Terra version: 0.25.0
  • Python version: 3.10
  • Operating system: Ubuntu

What is happening?

When a delay gate is created with units that are not dt, qpy doesn't keep track of the units.

How can we reproduce the issue?

import qiskit
from qiskit import qpy

qc = qiskit.QuantumCircuit(1)
qc.delay(10, unit="s")

print(qc)
# prints
#     ┌──────────────┐
#  q: ┤ Delay(10[s]) ├
#     └──────────────┘
# c: 1/════════════════


with open('delay.qpy', 'wb') as fd:
    qpy.dump(qc, fd)

with open('delay.qpy', 'rb') as fd:
    new_qc = qpy.load(fd)[0]
    
    
print(new_qc)
# prints
#     ┌───────────────┐
#  q: ┤ Delay(10[dt]) ├
#     └───────────────┘
#  c: 1/═════════════════

print(str(qc) == str(new_qc))
# prints
# False

What should happen?

print(str(qc) == str(new_qc)) should print True

Any suggestions?

No response

Metadata

Metadata

Labels

bugSomething isn't workingmod: qpyRelated to QPY serialization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions