|
1 | 1 | import time
|
2 | 2 | from collections import defaultdict
|
3 |
| -from functools import cached_property |
| 3 | +from functools import cached_property, reduce |
4 | 4 | from itertools import groupby
|
5 | 5 | from typing import Optional, cast
|
6 | 6 |
|
@@ -58,13 +58,26 @@ def batch_shots(
|
58 | 58 | nfull, remainder = np.divmod(bins * samples, ACQUISITION_MEMORY)
|
59 | 59 | return (
|
60 | 60 | [ACQUISITION_MEMORY] * nfull + [remainder]
|
61 |
| - if options.averaging_mode is not AveragingMode.SINGLESHOT |
| 61 | + if options.averaging_mode is AveragingMode.SINGLESHOT |
62 | 62 | else [options.nshots]
|
63 | 63 | )
|
64 | 64 |
|
65 | 65 |
|
66 |
| -def concat_shots(results: list[dict[int, Result]]) -> dict[int, Result]: |
67 |
| - return results[0] |
| 66 | +def concat_shots( |
| 67 | + results: list[dict[int, Result]], options: ExecutionParameters |
| 68 | +) -> dict[int, Result]: |
| 69 | + """Concatenate shots batches. |
| 70 | +
|
| 71 | + It collects the measurements' batches resulting from the subdivision generated by |
| 72 | + the :func:`batch_shots` function. |
| 73 | + It assumes homogenuous batches, which are only joined over the single outermost |
| 74 | + dimension, and only for :obj:`AveragingMode.SINGLESHOT` acquisitions. |
| 75 | + """ |
| 76 | + return ( |
| 77 | + reduce(lambda d, e: {k: np.vstack((v, e[k])) for k, v in d.items()}, results) |
| 78 | + if options.averaging_mode is AveragingMode.SINGLESHOT |
| 79 | + else results[0] |
| 80 | + ) |
68 | 81 |
|
69 | 82 |
|
70 | 83 | class Cluster(Controller):
|
@@ -218,7 +231,7 @@ def play(
|
218 | 231 | options.results_shape(sweepers),
|
219 | 232 | )
|
220 | 233 | )
|
221 |
| - results |= concat_shots(psres) |
| 234 | + results |= concat_shots(psres, options) |
222 | 235 | return results
|
223 | 236 |
|
224 | 237 | def _configure(
|
|
0 commit comments