Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nkanazawa1989 committed Apr 21, 2022
1 parent e246f71 commit 4cd5b8f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def _default_options(cls):
gate_error_ratio (Optional[Dict[str, float]]): A dictionary with gate name keys
and error ratio values used when calculating EPG from the estimated EPC.
The default value will use standard gate error ratios.
If set to ``False`` EPG will not be calculated.
If you don't know accurate error ratio between your basis gates,
you can skip analysis of EPGs by setting this options to ``None``.
epg_1_qubit (List[DbAnalysisResultV1]): Analysis results from previous RB experiments
for individual single qubit gates. If this is provided, EPC of
2Q RB is corected to exclude the deporalization of underlying 1Q channels.
Expand Down Expand Up @@ -241,7 +242,7 @@ def _run_analysis(
self, experiment_data: ExperimentData
) -> Tuple[List[AnalysisResultData], List["pyplot.Figure"]]:

if self.options.gate_error_ratio:
if self.options.gate_error_ratio is not None:
# If gate error ratio is not False, EPG analysis is enabled.
# Here analysis prepares gate error ratio and gate counts for EPC to EPG conversion.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _transpiled_circuits(self) -> List[QuantumCircuit]:
"""Return a list of experiment circuits, transpiled."""
transpiled = super()._transpiled_circuits()

if not self.analysis.options.get("gate_error_ratio", None):
if self.analysis.options.get("gate_error_ratio", None) is None:
# Gate errors are not computed, then counting ops is not necessary.
return transpiled

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def get_error_dict_from_backend(
return None
return error_dict

@staticmethod
@staticmethod
@deprecated_function(
last_version="0.4",
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ qiskit-terra>=0.19.0
qiskit-ibmq-provider>=0.16.0
matplotlib>=3.4
uncertainties

26 changes: 5 additions & 21 deletions test/randomized_benchmarking/test_randomized_benchmarking.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_single_qubit(self):
seed=123,
backend=self.backend,
)
exp.analysis.set_options(gate_error_ratio=False)
exp.analysis.set_options(gate_error_ratio=None)
exp.set_transpile_options(**self.transpiler_options)
self.assertAllIdentity(exp.circuits())

Expand All @@ -115,7 +115,7 @@ def test_two_qubit(self):
seed=123,
backend=self.backend,
)
exp.analysis.set_options(gate_error_ratio=False)
exp.analysis.set_options(gate_error_ratio=None)
exp.set_transpile_options(**self.transpiler_options)
self.assertAllIdentity(exp.circuits())

Expand All @@ -141,7 +141,7 @@ def test_add_more_circuit_yields_lower_variance(self):
backend=self.backend,
num_samples=3,
)
exp1.analysis.set_options(gate_error_ratio=False)
exp1.analysis.set_options(gate_error_ratio=None)
exp1.set_transpile_options(**self.transpiler_options)
expdata1 = exp1.run()
self.assertExperimentDone(expdata1)
Expand All @@ -153,7 +153,7 @@ def test_add_more_circuit_yields_lower_variance(self):
backend=self.backend,
num_samples=5,
)
exp2.analysis.set_options(gate_error_ratio=False)
exp2.analysis.set_options(gate_error_ratio=None)
exp2.set_transpile_options(**self.transpiler_options)
expdata2 = exp2.run()
self.assertExperimentDone(expdata2)
Expand Down Expand Up @@ -346,22 +346,6 @@ def test_non_clifford_interleaved_element(self):
lengths=lengths,
)

def test_interleaving_delay(self):
"""Test delay instruction can be interleaved."""
# See qiskit-experiments/#727 for details
interleaved_element = Delay(10, unit="us")
exp = rb.InterleavedRB(
interleaved_element,
qubits=[0],
lengths=[1],
num_samples=1,
)
# Not raises an error
_, int_circ = exp.circuits()

# barrier, clifford, barrier, "delay", barrier, ...
self.assertEqual(int_circ.data[3][0], interleaved_element)

def test_experiment_config(self):
"""Test converting to and from config works"""
exp = rb.InterleavedRB(
Expand Down Expand Up @@ -491,7 +475,7 @@ def test_default_epg_ratio(self):
def test_no_epg(self):
"""Calculate no EPGs."""
analysis = rb.RBAnalysis()
analysis.set_options(outcome="0", gate_error_ratio=False)
analysis.set_options(outcome="0", gate_error_ratio=None)
result = analysis.run(self.expdata_1qrb_q0, replace_results=False)
self.assertExperimentDone(result)

Expand Down

0 comments on commit 4cd5b8f

Please sign in to comment.