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
9 changes: 3 additions & 6 deletions qiskit_experiments/framework/composite/composite_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@ def _run_analysis(self, experiment_data: ExperimentData):
)
analysis_results.append(result)

# Add callback to wait for all component analysis to finish before returning
# Wait for all component analysis to finish before returning
# the parent experiment analysis results
def _wait_for_components(experiment_data, component_ids):
for comp_id in component_ids:
experiment_data.child_data(comp_id).block_for_results()

experiment_data.add_analysis_callback(_wait_for_components, component_ids=component_ids)
for comp_id in component_ids:
experiment_data.child_data(comp_id).block_for_results()

return analysis_results, []

Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/fix-nested-comp-66a2b8b6e3b404be.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixes bug in :class:`.CompositeAnalysis` where analysis of nested
composite experiments could raise a RuntimeError.
14 changes: 14 additions & 0 deletions test/test_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ def test_composite_copy(self):
self.check_attributes(new_instance)
self.assertEqual(new_instance.parent_id, None)

def test_nested_composite(self):
"""
Test nested parallel experiments.
"""
exp1 = FakeExperiment([0, 2])
exp2 = FakeExperiment([1, 3])
exp3 = ParallelExperiment([exp1, exp2])
exp4 = BatchExperiment([exp3, exp1])
exp5 = ParallelExperiment([exp4, FakeExperiment([4])])
nested_exp = BatchExperiment([exp5, exp3])
expdata = nested_exp.run(FakeBackend()).block_for_results()
status = expdata.status()
self.assertEqual(status, "DONE")

def test_analysis_replace_results_true(self):
"""
Test replace results when analyzing composite experiment data
Expand Down