Skip to content

Commit

Permalink
Commit before merge qiskit-community#1268
Browse files Browse the repository at this point in the history
  • Loading branch information
Musa-Sina-Ertugrul committed Apr 22, 2024
1 parent e4c20a1 commit d9dd408
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 182 deletions.
9 changes: 6 additions & 3 deletions qiskit_experiments/framework/composite/composite_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,14 @@ def copy(self):
def _run_analysis(self, experiment_data: ExperimentData):
child_data = experiment_data.child_data()

if len(self._analyses) != len(child_data):
# Child data is automatically created when composite result data is added.
# Validate that child data size matches with number of analysis entries.
if len(child_data) == 0:
# Child data is automatically created when composite result data is added.
# Validate that child data size matches with number of analysis entries.
experiment_data.create_child_data()

if len(self._analyses) != len(child_data):
raise("analysis length and experiment lenggth are not same")

for sub_analysis, sub_data in zip(self._analyses, child_data):
# Since copy for replace result is handled at the parent level
# we always run with replace result on component analysis
Expand Down
16 changes: 6 additions & 10 deletions qiskit_experiments/framework/experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,11 @@ def add_data(
else:
raise TypeError(f"Invalid data type {type(datum)}.")
self.create_child_data()
self.init_children_data()
self._init_children_data()

@property
def __retrive_self_attrs_as_dict(self) -> dict:

"""
retrive data about self to bootstrap
"""

return {
"backend": self.backend,
"tags": self.tags,
Expand All @@ -763,12 +759,12 @@ def __retrive_self_attrs_as_dict(self) -> dict:
"experiment_type": self.experiment_type,
}

def create_child_data(self): # pylint: disable=inconsistent-return-statements
def create_child_data(self) -> "ExperimenData": # pylint: disable=inconsistent-return-statements

"""Bootstrap Experiment data containers
"""Bootstrap child experiment data containers from result metadata.
Returns:
self : return itself for method calling
Returns:
Current instance populated with the child experiment data.
"""

if (component_metadata := self.metadata.get("component_metadata", None)) is None:
Expand All @@ -791,7 +787,7 @@ def create_child_data(self): # pylint: disable=inconsistent-return-statements

return self

def init_children_data(self): # pylint: disable=inconsistent-return-statements
def _init_children_data(self): # pylint: disable=inconsistent-return-statements

"""Bootstrap Experiment data containers's data
Expand Down
Loading

0 comments on commit d9dd408

Please sign in to comment.