Result
Result dataclass
Result(
*,
storage: StorageBackend,
shot_filter: ShotFilter = _default_shot_filter()
)
Result view over stored shots.
Merge-oriented methods assume each selected task ID has the same subtask structure.
Attributes:
| Name | Type | Description |
|---|---|---|
storage | StorageBackend | Storage backend that holds shots and task metadata. |
shot_filter | ShotFilter | Filter used when reading shots and deriving subtask scope. Defaults to the DETECTED frame type. |
storage_filter property
storage_filter: StorageFilter
Return the subtask-level portion of shot_filter.
Returns:
| Name | Type | Description |
|---|---|---|
StorageFilter | StorageFilter | Filter containing task IDs, subtask indices, and task-subtask pairs from |
arguments
arguments(verify: bool = True) -> list[dict | None]
Return subtask arguments after merging selected task IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verify | bool | Whether to validate that selected task IDs can be merged before reading arguments. Defaults to True. | True |
Returns:
| Type | Description |
|---|---|
list[dict | None] | list[dict | None]: One arguments entry per merged subtask, ordered by subtask index. |
Raises:
| Type | Description |
|---|---|
ValueError | If |
Source code in src/bloqade/core/device/result.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
full_arguments
full_arguments() -> list[dict | None]
Return all stored subtask arguments without merging task IDs.
Returns:
| Type | Description |
|---|---|
list[dict | None] | list[dict | None]: Arguments for every selected stored subtask row, including |
Source code in src/bloqade/core/device/result.py
162 163 164 165 166 167 168 169 | |
full_subtasks
full_subtasks() -> list[dict]
Return selected stored subtasks without merging task IDs.
If selected task IDs share the same subtask structure, this view contains one row per task and subtask.
Returns:
| Type | Description |
|---|---|
list[dict] | list[dict]: Full subtask dictionaries selected by |
Source code in src/bloqade/core/device/result.py
205 206 207 208 209 210 211 212 213 214 | |
shot_results
shot_results(verify: bool = True) -> list[np.ndarray]
Return physical shot bitstrings grouped by merged subtask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verify | bool | Whether to validate that selected task IDs can be merged before reading shots. Defaults to True. | True |
Returns:
| Type | Description |
|---|---|
list[ndarray] | list[np.ndarray]: One two-dimensional boolean array per merged subtask, ordered by subtask index. |
Raises:
| Type | Description |
|---|---|
ValueError | If |
Source code in src/bloqade/core/device/result.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
subtasks
subtasks(verify: bool = True) -> list[dict]
Return subtasks merged across selected task IDs.
The merged view is ordered by subtask_index, removes ambiguous per-task fields (task_id and metadata), and aggregates num_shots. Use full_subtasks when task IDs or metadata must be preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verify | bool | Whether to validate that selected task IDs can be merged before returning subtasks. Defaults to True. | True |
Returns:
| Type | Description |
|---|---|
list[dict] | list[dict]: Merged subtask dictionaries ordered by subtask index. |
Raises:
| Type | Description |
|---|---|
ValueError | If |
Source code in src/bloqade/core/device/result.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
task_ids
task_ids() -> set[str]
Return task IDs selected by this result view.
Returns:
| Type | Description |
|---|---|
set[str] | set[str]: Task IDs from |
Source code in src/bloqade/core/device/result.py
216 217 218 219 220 221 222 223 224 225 226 | |
validate
validate() -> None
Validate that selected task IDs can be merged by subtask index.
Compatible task IDs have the same program_index and equal arguments for each shared subtask_index. Different shot counts are allowed, and None and empty dictionaries are treated as equivalent arguments.
Raises:
| Type | Description |
|---|---|
ValueError | If selected task IDs disagree on |
Source code in src/bloqade/core/device/result.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
where_arguments
where_arguments(
predicate: Callable[[dict | None], bool],
) -> Self
Return a result narrowed by subtask arguments.
The predicate sees only subtasks in the scope of self.shot_filter; the returned result inherits that scope intersected with the matches.
NOTE: the Subtask model coerces bool values in arguments to float (True -> 1.0, False -> 0.0). Predicates that rely on identity (is True) or strict types will silently match nothing for bool-valued arguments. Use == 1 or > 0 instead, or store non-bool discriminators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate | Callable[[dict | None], bool] | Predicate applied to each selected subtask's arguments. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Self | Self | A narrowed result view. |
Source code in src/bloqade/core/device/result.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
where_metadata
where_metadata(
predicate: Callable[[dict | None], bool],
) -> Self
Return a result narrowed by JSON-decoded user metadata.
Expects user_metadata to be a JSON-serialized dict; non-JSON values raise. To filter on raw strings instead, use where_subtasks and parse manually. The predicate sees only subtasks in the scope of self.shot_filter; the returned result inherits that scope intersected with the matches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate | Callable[[dict | None], bool] | Predicate applied to each selected subtask's decoded | required |
Returns:
| Name | Type | Description |
|---|---|---|
Self | Self | A narrowed result view. |
Source code in src/bloqade/core/device/result.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
where_shots
where_shots(
predicate: Callable[[ShotResult], bool],
predicate_filter: ShotFilter | None = None,
) -> Self
Return a result narrowed by shot-level predicate.
predicate_filter selects the shots the predicate evaluates against; defaults to self.shot_filter (predicate sees the same shots the current result fetches). The returned result inherits self.shot_filter's scope (notably frame_type) intersected with the matching shot pairs.
To precondition on one frame and return another, such as SORTED-was-all-1 -> DETECTED, pass predicate_filter=replace(self.shot_filter, frame_type='SORTED').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate | Callable[[ShotResult], bool] | Predicate applied to each shot selected by | required |
predicate_filter | ShotFilter | None | Filter used only for predicate evaluation. When None, | None |
Returns:
| Name | Type | Description |
|---|---|---|
Self | Self | A narrowed result view. |
Source code in src/bloqade/core/device/result.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
where_subtasks
where_subtasks(predicate: Callable[[dict], bool]) -> Self
Return a result narrowed to subtasks matching a predicate.
The predicate sees only subtasks in the scope of self.shot_filter; the returned result inherits that scope intersected with the matches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate | Callable[[dict], bool] | Predicate applied to each selected subtask dictionary. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Self | Self | A narrowed result view. |
Source code in src/bloqade/core/device/result.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |