-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
- Qiskit version:
a00279bc7d6005bfc5ea783cd1fe336784160518
- Python version: 3.11
- Operating system: macOS Sonoma 14.4
What is happening?
After pickling, DAGCircuit
is no longer equal to itself if it contains variables.
This issue predates all changes made in support of stretch
(the above test fails on the commit prior to the first PR in that series).
How can we reproduce the issue?
def test_pickle_identifiers(self):
"""Test identifiers preserved through pickle."""
a = expr.Var.new("a", types.Bool())
b = expr.Var.new("b", types.Uint(8))
# Check captures and declarations.
dag = DAGCircuit()
dag.add_declared_var(a)
dag.add_captured_var(b)
self.assertEqual(dag.num_vars, 2)
self.assertEqual(dag.num_captured_vars, 1)
self.assertEqual(dag.num_declared_vars, 1)
with io.BytesIO() as buf:
pickle.dump(dag, buf)
buf.seek(0)
output = pickle.load(buf)
self.assertEqual(output.num_vars, 2)
self.assertEqual(output.num_captured_vars, 1)
self.assertEqual(output.num_declared_vars, 1)
self.assertEqual(output, dag) # < --- FAILS
What should happen?
The circuits should be equal.
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working