Skip to content

Commit b26d579

Browse files
committed
Add more documentation
1 parent 3aa2065 commit b26d579

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

qiskit_experiments/base_experiment.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ def _transpile(
191191
@classmethod
192192
def _default_options(cls) -> Options:
193193
"""Default kwarg options for experiment"""
194+
# Experiment subclasses should override this method to return
195+
# an `Options` object containing all the supported options for
196+
# that experiment and their default values. Only options listed
197+
# here can be modified later by the `set_options` method.
194198
return Options()
195199

196200
@property
@@ -217,6 +221,9 @@ def set_options(self, **fields):
217221
@classmethod
218222
def _default_transpile_options(cls) -> Options:
219223
"""Default transpiler options for transpilation of circuits"""
224+
# Experiment subclasses can override this method if they need
225+
# to set specific transpiler options defaults for running the
226+
# experiment.
220227
return Options(optimization_level=0)
221228

222229
@property
@@ -260,8 +267,10 @@ def set_backend_options(self, **fields):
260267

261268
@classmethod
262269
def _default_analysis_options(cls) -> Options:
263-
"""Default transpiler options for transpilation of circuits"""
264-
# These should typically be set by the analysis class default options
270+
"""Default options for analysis of experiment results."""
271+
# Experiment subclasses can override this method if they need
272+
# to set specific analysis options defaults that are different
273+
# from the Analysis subclass `_default_options` values.
265274
if cls.__analysis_class__:
266275
return cls.__analysis_class__._default_options()
267276
return None

qiskit_experiments/characterization/t1_experiment.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ def _format_plot(cls, ax, analysis_result, qubit=None, add_label=True):
196196

197197

198198
class T1Experiment(BaseExperiment):
199-
"""T1 experiment class"""
199+
"""T1 experiment class.
200+
201+
Experiment Options:
202+
delays: delay times of the experiments
203+
unit: Optional, unit of the delay times. Supported units are
204+
's', 'ms', 'us', 'ns', 'ps', 'dt'.
205+
"""
200206

201207
__analysis_class__ = T1Analysis
202208

qiskit_experiments/randomized_benchmarking/rb_analysis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"""
1515

1616
from typing import Optional, List
17-
import numpy as np
1817

1918
from qiskit.providers.options import Options
2019
from qiskit_experiments.base_analysis import BaseAnalysis

qiskit_experiments/randomized_benchmarking/rb_experiment.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@
2020
from qiskit import QuantumCircuit
2121
from qiskit.providers import Backend
2222
from qiskit.quantum_info import Clifford, random_clifford
23+
from qiskit.providers.options import Options
2324

2425
from qiskit_experiments.base_experiment import BaseExperiment
2526
from .rb_analysis import RBAnalysis
2627

2728

2829
class RBExperiment(BaseExperiment):
29-
"""RB Experiment class"""
30+
"""RB Experiment class.
31+
32+
Experiment Options:
33+
lengths: A list of RB sequences lengths.
34+
num_samples: number of samples to generate for each sequence length.
35+
"""
3036

3137
# Analysis class for experiment
3238
__analysis_class__ = RBAnalysis
@@ -45,8 +51,7 @@ def __init__(
4551
qubits: the number of qubits or list of
4652
physical qubits for the experiment.
4753
lengths: A list of RB sequences lengths.
48-
num_samples: number of samples to generate for each
49-
sequence length
54+
num_samples: number of samples to generate for each sequence length.
5055
seed: Seed or generator object for random number
5156
generation. If None default_rng will be used.
5257
full_sampling: If True all Cliffords are independently sampled for
@@ -58,10 +63,12 @@ def __init__(
5863
self._rng = default_rng(seed=seed)
5964
else:
6065
self._rng = seed
61-
self._lengths = list(lengths)
62-
self._num_samples = num_samples
6366
self._full_sampling = full_sampling
64-
super().__init__(qubits)
67+
super().__init__(qubits, lenghs=list(lengths), num_samples=num_samples)
68+
69+
@classmethod
70+
def _default_options(cls):
71+
return Options(lengths=None, num_samples=None)
6572

6673
# pylint: disable = arguments-differ
6774
def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
@@ -72,8 +79,8 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
7279
A list of :class:`QuantumCircuit`.
7380
"""
7481
circuits = []
75-
for _ in range(self._num_samples):
76-
circuits += self._sample_circuits(self._lengths, seed=self._rng)
82+
for _ in range(self.options.num_samples):
83+
circuits += self._sample_circuits(self.options.lengths, seed=self._rng)
7784
return circuits
7885

7986
def _sample_circuits(

0 commit comments

Comments
 (0)