CompositeAnalysis

class CompositeAnalysis(analyses, flatten_results=True, generate_figures='always')[source]

Run analysis for composite experiments.

Composite experiments consist of several component experiments run together in a single execution, the results of which are returned as a single list of circuit result data in the ExperimentData container.

Analysis of this composite circuit data involves constructing a list of experiment data containers for each component experiment containing the marginalized circuit result data for that experiment. These are saved as child_data() in the main ExperimentData container. Each component experiment data is then analyzed using the analysis class from the corresponding component experiment.

Note

If the composite ExperimentData does not already contain child experiment data containers for the component experiments they will be initialized and added to the experiment data when run() is called on the composite data.

When calling run() on experiment data already containing initialized component experiment data, any previously stored circuit data will be cleared and replaced with the marginalized data from the composite experiment data.

Initialize a composite analysis class.

Parameters:
  • analyses (List[BaseAnalysis]) – a list of component experiment analysis objects.

  • flatten_results (bool) – If True flatten all component experiment results into a single ExperimentData container, including nested composite experiments. If False save each component experiment results as a separate child ExperimentData container.

  • generate_figures (str | None) – Optional flag to set the figure generation behavior. If always, figures are always generated. If never, figures are never generated. If selective, figures are generated if the analysis quality is bad.

Attributes

options

Return the analysis options for run() method.

Methods

component_analysis(index=None)[source]

Return the component experiment Analysis instance.

Parameters:

index (int | None) – Optional, the component index to return analysis for. If None return a list of all component analysis instances.

Returns:

The analysis instance for the specified index, or a list of all analysis instances if index is None.

Return type:

BaseAnalysis | List[BaseAnalysis]

config()

Return the config dataclass for this analysis

Return type:

AnalysisConfig

copy()[source]

Return a copy of the analysis

classmethod from_config(config)

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 the experiment. If the broadcast argument set to True, the analysis options will cascade to the child experiments.