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
22 changes: 11 additions & 11 deletions qiskit_experiments/framework/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ def __init__(
# Experiment identification metadata
self._type = experiment_type if experiment_type else type(self).__name__

# Backend
self._backend = None
if isinstance(backend, (Backend, BaseBackend)):
self._set_backend(backend)

# Circuit parameters
if isinstance(qubits, Integral):
self._num_qubits = qubits
Expand All @@ -152,6 +147,13 @@ def __init__(
self._set_run_options = set()
self._set_analysis_options = set()

# Set backend
# This should be called last incase `_set_backend` access any of the
# attributes created during initialization
self._backend = None
if isinstance(backend, (Backend, BaseBackend)):
self._set_backend(backend)

def __new__(cls, *args, **kwargs):
"""Store init args and kwargs for subclass __init__ methods"""
# This method automatically stores all arg and kwargs from subclass
Expand Down Expand Up @@ -317,10 +319,9 @@ def run(

# Optionally run analysis
if analysis and self.__analysis_class__ is not None:
self.run_analysis(experiment_data)

# Return the ExperimentData future
return experiment_data
return self.run_analysis(experiment_data)
else:
return experiment_data

def _initialize_experiment_data(self) -> ExperimentData:
"""Initialize the return data container for the experiment run"""
Expand Down Expand Up @@ -355,8 +356,7 @@ def run_analysis(

# Run analysis
analysis = self.analysis()
analysis.run(experiment_data, replace_results=replace_results, **analysis_options)
return experiment_data
return analysis.run(experiment_data, replace_results=replace_results, **analysis_options)

def _run_jobs(self, circuits: List[QuantumCircuit], **run_options) -> List[BaseJob]:
"""Run circuits on backend as 1 or more jobs."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,4 @@ def block_for_results(self, timeout: Optional[float] = None):
_, timeout = combined_timeout(super().block_for_results, timeout)
for subdata in self._components:
_, timeout = combined_timeout(subdata.block_for_results, timeout)
return self