Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

BaseAnalysis

class BaseAnalysis[source]

Abstract base class for analyzing Experiment data.

The data produced by experiments (i.e. subclasses of BaseExperiment) are analyzed with subclasses of BaseAnalysis. The analysis is typically run after the data has been gathered by the experiment. For example, an analysis may perform some data processing of the measured data and a fit to a function to extract a parameter.

Analysis subclasses must implement the abstract method _run_analysis. This method should not have side-effects on the analysis class itself since it could potentially be called asynchronously in multiple threads. Any configurable option values should be specified in the _default_options class method. These values can be overriden by a user by calling the set_options method or for a single-run can be specified by passing kwarg options to the run() method.

Initialize the analysis object.

Attributes

options

Return the analysis options for run() method.

Methods

config()[source]

Return the config dataclass for this analysis

Return type:

AnalysisConfig

copy()[source]

Return a copy of the analysis

Return type:

BaseAnalysis

classmethod from_config(config)[source]

Initialize an analysis class from analysis config

Return type:

BaseAnalysis

run(experiment_data, replace_results=False, **options)[source]

Run analysis and update ExperimentData with analysis result.

Parameters:
  • experiment_data (ExperimentData) – the experiment data to analyze.

  • replace_results (bool) – If True clear any existing analysis results, figures, and artifacts in the experiment data and replace with new results. See note for additional information.

  • options – additional analysis options. See class documentation for supported options.

Returns:

An experiment data object containing analysis results, figures, and artifacts.

Raises:

QiskitError – If experiment_data container is not valid for analysis.

Return type:

ExperimentData

Note

Updating Results

If analysis is run with replace_results=True then any analysis results, figures, and artifacts in the experiment data will be cleared and replaced with the new analysis results. Saving this experiment data will replace any previously saved data in a database service using the same experiment ID.

If analysis is run with replace_results=False and the experiment data being analyzed has already been saved to a database service, or already contains analysis results or figures, a copy with a unique experiment ID will be returned containing only the new analysis results and figures. This data can then be saved as its own experiment to a database service.

set_options(**fields)[source]

Set the analysis options for run() method.

Parameters:

fields – The fields to update the options