Skip to content

Commit

Permalink
Add test and release note
Browse files Browse the repository at this point in the history
- This commit adds a release note and a test.
- Tests were done with qiskit version 1.1
  • Loading branch information
amaloney committed Jun 14, 2024
1 parent 91829da commit 28a9503
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions releasenotes/notes/qpy-serialization-f08c241209706da2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
features_qpy:
- |
qiskit.qpy now saves and loads circuits reliably using
`qiskit.qpy.dump` and `qiskit.qpy.load`. Previously, an
error was thrown requiring a positional argument `theta` that is
now computed generated in the gate method.
upgrade_qpy:
- |
Works in 1.x and may need a backport for 0.4x.
31 changes: 31 additions & 0 deletions test/python/qpy/test_io_from_qpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Test cases for qpy loading and saving."""

import io

from qiskit import QuantumCircuit
from qiskit.qpy import dump, load


def test_io():
circuit = QuantumCircuit(2)
circuit.ms(1.23, [0, 1])

buf = io.BytesIO()
dump(circuit, buf)

try:
_ = load(io.BytesIO(buf.getvalue()))
except Exception as e:
raise IOError("Loading to and from qpy failed.") from e

0 comments on commit 28a9503

Please sign in to comment.