Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions docs/_ext/custom_styles/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ def _extra_sections(self) -> Dict[str, List[str]]:
"""Generate extra sections."""
parsed_sections = {}

# add analysis class reference
analysis_class = getattr(self._target_cls, "__analysis_class__", None)
if analysis_class:
analysis_ref = f":py:class:`~{analysis_class.__module__}.{analysis_class.__name__}`"
parsed_sections["analysis_ref"] = [analysis_ref]

# add experiment option
exp_option_desc = []

Expand All @@ -213,36 +207,6 @@ def _extra_sections(self) -> Dict[str, List[str]]:

parsed_sections["experiment_opts"] = exp_option_desc

# add analysis option
analysis_option_desc = []

if analysis_class:
default_analysis_options = self._target_cls._default_analysis_options().__dict__

analysis_docs_config = copy.copy(self._config)
analysis_docs_config.napoleon_custom_sections = [("analysis options", "args")]
analysis_option = _generate_options_documentation(
current_class=analysis_class,
method_name="_default_options",
target_args=list(default_analysis_options.keys()),
config=analysis_docs_config,
indent=self._indent,
)

if analysis_option:
analysis_option_desc.extend(analysis_option)
analysis_option_desc.append("")
analysis_option_desc.extend(
_format_default_options(
defaults=default_analysis_options,
indent=self._indent,
)
)
else:
analysis_option_desc.append("No analysis option available for this experiment.")

parsed_sections["analysis_opts"] = analysis_option_desc

# add transpiler option
transpiler_option_desc = [
"This option is used for circuit optimization. ",
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/quantum_volume.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@
],
"source": [
"qv_exp.set_experiment_options(trials=60)\n",
"expdata2 = qv_exp.run(backend, analysis=False).block_for_results()\n",
"expdata2 = qv_exp.run(backend, analysis=None).block_for_results()\n",
"expdata2.add_data(expdata.data())\n",
"qv_exp.run_analysis(expdata2).block_for_results()\n",
"qv_exp.analysis.run(expdata2).block_for_results()\n",
"\n",
"# View result data\n",
"display(expdata2.figure(0))\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/randomized_benchmarking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"exp2 = StandardRB(qubits, lengths, num_samples=num_samples, seed=seed)\n",
"\n",
"# Use the EPG data of the 1-qubit runs to ensure correct 2-qubit EPG computation\n",
"exp2.set_analysis_options(epg_1_qubit=epg_1q)\n",
"exp2.analysis.set_options(epg_1_qubit=epg_1q)\n",
"\n",
"# Run the 2-qubit experiment\n",
"expdata2 = exp2.run(backend).block_for_results()\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/state_tomography.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
" import cvxpy\n",
" \n",
" # Set analysis option for cvxpy fitter\n",
" qstexp1.set_analysis_options(fitter='cvxpy_gaussian_lstsq')\n",
" qstexp1.analysis.set_options(fitter='cvxpy_gaussian_lstsq')\n",
" \n",
" # Re-run experiment\n",
" qstdata2 = qstexp1.run(backend, seed_simulation=100).block_for_results()\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/t2ramsey_characterization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
" \"B\": 0.5\n",
" }\n",
"exp_with_p0 = T2Ramsey(qubit, delays, unit=unit, osc_freq=1e5)\n",
"exp_with_p0.set_analysis_options(p0=user_p0)\n",
"exp_with_p0.analysis.set_options(p0=user_p0)\n",
"expdata_with_p0 = exp_with_p0.run(backend=backend, shots=2000)\n",
"expdata_with_p0.block_for_results()\n",
"\n",
Expand Down Expand Up @@ -380,7 +380,7 @@
" \"phi\": 0,\n",
" \"B\": 0.5\n",
"}\n",
"exp_in_ns.set_analysis_options(p0=user_p0_ns)\n",
"exp_in_ns.analysis.set_options(p0=user_p0_ns)\n",
"\n",
"# Run experiment\n",
"expdata_in_ns = exp_in_ns.run(backend=backend_in_ns, shots=2000).block_for_results()\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"""Base class for calibration-type experiments."""

from abc import ABC
from typing import List, Optional, Type
from typing import List, Optional, Type, Union
import warnings

from qiskit.providers.backend import Backend
from qiskit.pulse import ScheduleBlock

from qiskit_experiments.calibration_management.calibrations import Calibrations
from qiskit_experiments.calibration_management.update_library import BaseUpdater
from qiskit_experiments.framework.base_analysis import BaseAnalysis
from qiskit_experiments.framework.base_experiment import BaseExperiment
from qiskit_experiments.framework.experiment_data import ExperimentData
from qiskit_experiments.exceptions import CalibrationError
Expand Down Expand Up @@ -79,9 +80,6 @@ class should be this mixin and the second class should be the characterization
:mod:`qiskit_experiments.calibration_management.update_library`. See also
:class:`qiskit_experiments.calibration_management.update_library.BaseUpdater`. If no updater
is specified the experiment will still run but no update of the calibrations will be performed.

In addition to the calibration specific requirements, the developer must set the analysis method
with the class variable :code:`__analysis_class__` and any default experiment options.
"""

def __init_subclass__(cls, **kwargs):
Expand Down Expand Up @@ -222,7 +220,7 @@ def _add_cal_metadata(self, experiment_data: ExperimentData):
def run(
self,
backend: Optional[Backend] = None,
analysis: bool = True,
analysis: Optional[Union[BaseAnalysis, None]] = "default",
**run_options,
) -> ExperimentData:
"""Run an experiment, perform analysis, and update any calibrations.
Expand All @@ -231,7 +229,10 @@ def run(
backend: Optional, the backend to run the experiment on. This
will override any currently set backends for the single
execution.
analysis: If True run analysis on the experiment data.
analysis: Optional, a custom analysis instance to use for performing
analysis. If None analysis will not be run. If ``"default"``
the experiments :meth:`analysis` instance will be used if
it contains one.
run_options: backend runtime options used for circuit execution.

Returns:
Expand Down
11 changes: 11 additions & 0 deletions qiskit_experiments/curve_analysis/standard_analysis/resonance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import numpy as np

import qiskit_experiments.curve_analysis as curve
from qiskit_experiments.framework import Options


class ResonanceAnalysis(curve.CurveAnalysis):
Expand Down Expand Up @@ -67,6 +68,16 @@ class ResonanceAnalysis(curve.CurveAnalysis):
)
]

@classmethod
def _default_options(cls) -> Options:
options = super()._default_options()
options.result_parameters = [curve.ParameterRepr("freq", "f01", "Hz")]
options.normalization = True
options.xlabel = "Frequency"
options.ylabel = "Signal (arb. units)"
options.xval_unit = "Hz"
return options

def _generate_fit_guesses(
self, user_opt: curve.FitOptions
) -> Union[curve.FitOptions, List[curve.FitOptions]]:
Expand Down
3 changes: 0 additions & 3 deletions qiskit_experiments/framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@
Arguments in the constructor can be overridden so that a subclass can
be initialized with some experiment configuration.

- Set :attr:`BaseExperiment.__analysis_class__` class attribute to
specify the :class:`BaseAnalysis` subclass for analyzing result data.

Optionally the following methods can also be overridden in the subclass to
allow configuring various experiment and execution options

Expand Down
Loading