Skip to content

Commit

Permalink
fix: Introduce results final reshape
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Feb 21, 2025
1 parent ee911a7 commit c9be1e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/qibolab/_core/execution_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ def bins(self, sweepers: list[ParallelSweepers]) -> tuple[int, ...]:
return shots + sweeps

def results_shape(
self, sweepers: list[ParallelSweepers], samples: Optional[int] = None
self, sweepers: list[ParallelSweepers], samples: int = -1
) -> tuple[int, ...]:
"""Compute the expected shape for collected data."""

inner = {
AcquisitionType.DISCRIMINATION: (),
AcquisitionType.INTEGRATION: (2,),
Expand Down
6 changes: 4 additions & 2 deletions src/qibolab/_core/instruments/qblox/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def play(
)
log.data(data)
lenghts = integration_lenghts(sequences_, sequencers, self._modules)
results_ |= extract(data, lenghts, options.acquisition_type)
results_ |= extract(
data, lenghts, options.acquisition_type, options.results_shape(sweepers)
)
return results_

def _configure(
Expand Down Expand Up @@ -234,7 +236,7 @@ def _execute(
self.cluster.get_acquisition_status(slot, seq, timeout=1)
if acquisition is AcquisitionType.RAW:
for name in seq_acqs:
self.cluster.store_scope_acquisition(slot, seq, str(name))
self.cluster.store_scope_acquisition(slot, seq, name)
acquisitions[ch] = self.cluster.get_acquisitions(slot, seq)

return acquisitions
3 changes: 2 additions & 1 deletion src/qibolab/_core/instruments/qblox/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def extract(
acquisitions: dict[ChannelId, AcquiredData],
lengths: dict[acquisition.MeasureId, int],
acquisition: AcquisitionType,
shape: tuple[int, ...],
) -> dict[PulseId, Result]:
# TODO: check if the `lengths` info coincide with the
# idata["acquisition"]["bins"]["avg_cnt"]
Expand All @@ -121,7 +122,7 @@ def extract(
else _scope(idata["acquisition"]["scope"])
if acquisition is AcquisitionType.RAW
else np.array([])
)
).reshape(shape)
for data in acquisitions.values()
for acq, idata in data.items()
}

0 comments on commit c9be1e9

Please sign in to comment.