Skip to content

Commit 3e2b180

Browse files
committed
Address review comments
* Rename Experiment.options to Experiment.experiment_options. * Add some more comments
1 parent 1795be8 commit 3e2b180

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

qiskit_experiments/base_analysis.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
class BaseAnalysis(ABC):
2929
"""Base Analysis class for analyzing Experiment data.
3030
31+
The data produced by experiments (i.e. subclasses of BaseExperiment)
32+
are analyzed with subclasses of BaseExperiment. The analysis is
33+
typically run after the data has been gathered by the experiment.
34+
For example, an analysis may perform some data processing of the
35+
measured data and a fit to a function to extract a parameter.
36+
3137
When designing Analysis subclasses default values for any kwarg
3238
analysis options of the `run` method should be set by overriding
3339
the `_default_options` class method. When calling `run` these
34-
default values will combined with all other option kwargs in the
40+
default values will be combined with all other option kwargs in the
3541
run method and passed to the `_run_analysis` function.
3642
"""
3743

qiskit_experiments/base_experiment.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, qubits: Iterable[int], experiment_type: Optional[str] = None)
7171
raise QiskitError("Duplicate qubits in physical qubits list.")
7272

7373
# Experiment options
74-
self._options = self._default_options()
74+
self._experiment_options = self._default_experiment_options()
7575
self._transpile_options = self._default_transpile_options()
7676
self._run_options = self._default_run_options()
7777
self._analysis_options = self._default_analysis_options()
@@ -194,7 +194,7 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
194194
# generation
195195

196196
@classmethod
197-
def _default_options(cls) -> Options:
197+
def _default_experiment_options(cls) -> Options:
198198
"""Default kwarg options for experiment"""
199199
# Experiment subclasses should override this method to return
200200
# an `Options` object containing all the supported options for
@@ -203,11 +203,11 @@ def _default_options(cls) -> Options:
203203
return Options()
204204

205205
@property
206-
def options(self) -> Options:
206+
def experiment_options(self) -> Options:
207207
"""Return the options for the experiment."""
208-
return self._options
208+
return self._experiment_options
209209

210-
def set_options(self, **fields):
210+
def set_experiment_options(self, **fields):
211211
"""Set the experiment options.
212212
213213
Args:
@@ -217,18 +217,18 @@ def set_options(self, **fields):
217217
AttributeError: If the field passed in is not a supported options
218218
"""
219219
for field in fields:
220-
if not hasattr(self._options, field):
220+
if not hasattr(self._experiment_options, field):
221221
raise AttributeError(
222222
f"Options field {field} is not valid for {type(self).__name__}"
223223
)
224-
self._options.update_options(**fields)
224+
self._experiment_options.update_options(**fields)
225225

226226
@classmethod
227227
def _default_transpile_options(cls) -> Options:
228228
"""Default transpiler options for transpilation of circuits"""
229229
# Experiment subclasses can override this method if they need
230-
# to set specific transpiler options defaults for running the
231-
# experiment.
230+
# to set specific default transpiler options to transpile the
231+
# experiment circuits.
232232
return Options(optimization_level=0)
233233

234234
@property

qiskit_experiments/characterization/t1_experiment.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class T1Experiment(BaseExperiment):
221221
__analysis_class__ = T1Analysis
222222

223223
@classmethod
224-
def _default_options(cls) -> Options:
224+
def _default_experiment_options(cls) -> Options:
225225
return Options(delays=None, unit="s")
226226

227227
def __init__(
@@ -249,7 +249,7 @@ def __init__(
249249
super().__init__([qubit])
250250

251251
# Set experiment options
252-
self.set_options(delays=delays, unit=unit)
252+
self.set_experiment_options(delays=delays, unit=unit)
253253

254254
def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
255255
"""
@@ -264,30 +264,30 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
264264
Raises:
265265
AttributeError: if unit is dt but dt parameter is missing in the backend configuration
266266
"""
267-
if self.options.unit == "dt":
267+
if self.experiment_options.unit == "dt":
268268
try:
269269
dt_factor = getattr(backend.configuration(), "dt")
270270
except AttributeError as no_dt:
271271
raise AttributeError("Dt parameter is missing in backend configuration") from no_dt
272272

273273
circuits = []
274274

275-
for delay in self.options.delays:
275+
for delay in self.experiment_options.delays:
276276
circ = QuantumCircuit(1, 1)
277277
circ.x(0)
278278
circ.barrier(0)
279-
circ.delay(delay, 0, self.options.unit)
279+
circ.delay(delay, 0, self.experiment_options.unit)
280280
circ.barrier(0)
281281
circ.measure(0, 0)
282282

283283
circ.metadata = {
284284
"experiment_type": self._type,
285285
"qubit": self.physical_qubits[0],
286286
"xval": delay,
287-
"unit": self.options.unit,
287+
"unit": self.experiment_options.unit,
288288
}
289289

290-
if self.options.unit == "dt":
290+
if self.experiment_options.unit == "dt":
291291
circ.metadata["dt_factor"] = dt_factor
292292

293293
circuits.append(circ)

qiskit_experiments/randomized_benchmarking/rb_experiment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(
6363
super().__init__(qubits)
6464

6565
# Set configurable options
66-
self.set_options(lengths=list(lengths), num_samples=num_samples)
66+
self.set_experiment_options(lengths=list(lengths), num_samples=num_samples)
6767

6868
# Set fixed options
6969
self._full_sampling = full_sampling
@@ -85,8 +85,8 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
8585
A list of :class:`QuantumCircuit`.
8686
"""
8787
circuits = []
88-
for _ in range(self.options.num_samples):
89-
circuits += self._sample_circuits(self.options.lengths, seed=self._rng)
88+
for _ in range(self.experiment_options.num_samples):
89+
circuits += self._sample_circuits(self.experiment_options.lengths, seed=self._rng)
9090
return circuits
9191

9292
def _sample_circuits(

0 commit comments

Comments
 (0)