Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
16 changes: 13 additions & 3 deletions qiskit_experiments/framework/experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,11 +1099,21 @@ def _add_result_data(
if testres.data:
joined_data = testres.join_data()
outer_shape = testres.data.shape
if outer_shape:
average_params = (
result[i]
.metadata.get("circuit_metadata", {})
.get("average_params", False)
)
if (
outer_shape
and not average_params
and not isinstance(joined_data, BitArray)
):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic needs to be outer_shape and (not average_params or not isinstance(joined_data, BitArray)) or outer_shape and not (average_params and isinstance(joined_data, BitArray))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. thanks!

raise QiskitError(
f"Outer PUB dimensions {outer_shape} found in result. "
"Only unparameterized PUBs are currently supported by "
"qiskit-experiments."
"qiskit-experiments unless the circuit metadata "
"indicates to average them and it used meas_level=2."
)
else:
joined_data = None
Expand All @@ -1124,7 +1134,7 @@ def _add_result_data(
data["counts"] = testres.join_data(testres.data.keys()).get_counts()
data["memory"] = testres.join_data(testres.data.keys()).get_bitstrings()
# number of shots
data["shots"] = joined_data.num_shots
data["shots"] = len(data["memory"])
elif isinstance(joined_data, np.ndarray):
data["meas_level"] = 1
if joined_data.ndim == 1:
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/average-pub-params-f24fd73f817051ac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

features:
- |
Enable averaging PUB parameters in :class:`~.ExperimentData` when
the circuit metadata contain "average_params".
Loading