forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- This commit adds a release note and a test. - Tests were done with qiskit version 1.1
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
releasenotes/notes/qpy-serialization-f08c241209706da2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |