qiskit_noise_learning.data.RawData
class qiskit_noise_learning.data.RawData(datatree: DataTree)
Bases: LeveledData
Raw experimental outcome data associated with instruction sequences and classical registers.
This class is a wrapper around a 1-layer deep XArray DataTree with arbitrary string keys. Each leaf dataset contains:
-
Data variables:
data: The raw boolean data with dimensions("randomization", "shot", "bit").data_mask: A boolean mask with dimensions("randomization", "shot"), whereTruemarks a shot to exclude, following thenumpy.maconvention. Handles potential raggedness in the"shot"dimension across different randomizations, as well as the outcome of any post-selection.measurement_flips: A boolean array of measurement flips with dimensions("randomization", "bit").time_lbs: Lower bound on data acquisition times, with dimensions("randomization",), of type"datetime64[us]".time_ubs: Upper bound on data acquisition times, with dimensions("randomization",), of type"datetime64[us]".
-
Coordinates:
unbound_instruction_sequence: The unbound instruction sequence for the data, along dimension("randomization",), of typeInstructionSequence.fragment_depth: Integer array of fragment depths along dimension("randomization",).
-
Attrs:
creg_names: Ordered list of classical register names.clbit_qubit_idxs: Dictionary mapping creg names to arrays of measured qubit indices, where entryjis the physical qubit index measured into classical bitjof the register.creg_bit_boundaries: Dictionary mapping creg names to(start_idx, end_idx)tuples indicating the slice of the"bit"dimension for that register.
The "bit" dimension is every classical register concatenated in creg_names order, so that creg_bit_boundaries partitions it, and bit j of a register holds the outcome for physical qubit clbit_qubit_idxs[creg][j]. Note that a register need not measure in ascending qubit order, and that the same physical qubit may be measured by more than one register.
The registers stand in one-to-one correspondence with the measuring gates of the instruction sequences the data was gathered from, in the order those gates are traversed, so that the n-th name of creg_names holds the outcomes of the n-th measuring gate.
Datasets are grouped by creg metadata: two datasets with the same creg_names and clbit_qubit_idxs are merged along the "randomization" dimension.
Parameters
datatree – A datatree in the above format.
__init__
__init__(datatree: DataTree)
Methods
Kolumne „ 1 “ | Kolumne „ 2 “ |
|---|---|
__init__(datatree) | |
from_arrays(creg_names, clbit_qubit_idxs, ...) | Instantiate from data specified as arrays. |
merge(other) | Merge with another raw data set. |
Attributes
Kolumne „ 1 “ | Kolumne „ 2 “ |
|---|---|
datatree | The data tree. |
datatree
Type: DataTree
The data tree.
from_arrays
classmethod from_arrays(creg_names: list[str], clbit_qubit_idxs: dict[str, ndarray], instruction_sequences: list[InstructionSequence], data: list[ndarray[bool]], measurement_flips: list[ndarray[bool]], time_lbs: list[ndarray[datetime64]], time_ubs: list[ndarray[datetime64]])
Instantiate from data specified as arrays.
All instruction sequences must share the same creg structure (same creg_names and clbit_qubit_idxs). The resulting RawData contains a single-leaf datatree.
Parameters
- creg_names – Ordered list of classical register names.
- clbit_qubit_idxs – Dictionary mapping creg names to arrays of measured physical qubit indices, where entry
jis the physical qubit index measured into classical bitjof the register. - instruction_sequences – The list of instruction sequences used to generate the experiments.
- data – A list of outcome data for each instruction sequence for all classical registers. The data has dimensions
("randomization", "shot", "bit"). Bits are ordered according tocreg_namesorder, with each creg’s bits contiguous. - measurement_flips – A list of measurement flips to be applied to the data for each instruction sequence. Dimensions are
("randomization", "bit"). - time_lbs – A lower bound on the data collection time for each randomization for a given instruction sequence. The dimensions are
("randomization",). - time_ubs – An upper bound on the data collection time for each randomization for a given instruction sequence. The dimensions are
("randomization",).
merge
merge(other: Self) → Self
Merge with another raw data set.
Datasets with matching creg metadata (creg_names and clbit_qubit_idxs) are concatenated along the "randomization" dimension. Potential raggedness of the "shot" dimension is handled via the "data_mask" data variable.
Parameters
other – The other raw dataset.
Returns
The merged data.