Skip to content

Commit

Permalink
Added circuit serialization test to Standart RB experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
ItamarGoldman committed May 15, 2023
1 parent 9a42316 commit 4d954d2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/library/randomized_benchmarking/test_standard_rb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

"""Test for randomized benchmarking experiments."""
import copy
import io

from test.base import QiskitExperimentsTestCase
from test.library.randomized_benchmarking.mixin import RBTestMixin
from ddt import ddt, data, unpack

from qiskit import qpy
from qiskit.circuit.library import SXGate
from qiskit.exceptions import QiskitError
from qiskit.providers.fake_provider import FakeManilaV2
Expand Down Expand Up @@ -60,6 +62,17 @@ def test_roundtrip_serializable(self):
exp = rb.StandardRB(physical_qubits=(0,), lengths=[10, 20, 30], seed=123)
self.assertRoundTripSerializable(exp)

def test_circuit_serialization(self):
"""Test round trip qpy serialization"""
exp = rb.StandardRB(physical_qubits=(0,), lengths=[10, 20, 30], seed=123)
circs = exp.circuits()
qpy_file = io.BytesIO()
qpy.dump(circs, qpy_file)
qpy_file.seek(0)
new_circs = qpy.load(qpy_file)

self.assertEqual(circs, new_circs)

def test_analysis_config(self):
""" "Test converting analysis to and from config works"""
analysis = rb.RBAnalysis()
Expand Down

0 comments on commit 4d954d2

Please sign in to comment.