Skip to content

qek.data.processed_data

source module qek.data.processed_data

Loading, saving, manipulation or processed data.

Classes

  • ProcessedData Data on a single graph obtained from the Quantum Device.

Functions

  • dist_excitation Calculates the distribution of excitation energies from a dictionary of bitstrings to their respective counts.

  • save_dataset Saves a dataset to a JSON file.

  • load_dataset Loads a dataset from a JSON file.

source class ProcessedData(sequence: pl.Sequence, state_dict: dict[str, int | np.int64], target: int | None)

Data on a single graph obtained from the Quantum Device.

Attributes

  • register : pl.Register The geometry of atoms on the Quantum Device, obtained by compiling the graph for execution on the Quantum Device.

  • pulse : pl.Pulse The laser pulse, obtained by compiling the graph for execution on the Quantum Device.

  • state_dict : Final[dict[str, int]] A dictionary {bitstring: number of instances} for this graph.

  • target : Final[int | None] If specified, the machine-learning target, as a value 0 or 1.

Methods

source classmethod ProcessedData.custom(register: targets.Register, pulse: targets.Pulse, device: pl.devices.Device, state_dict: dict[str, int | np.int64], target: int | None)ProcessedData

source method ProcessedData.save_to_file(file_path: str)None

source method ProcessedData.dist_excitation(size: int | None = None)np.ndarray

Return the distribution of excitations for this graph.

Parameters

  • size : int | None If specified, truncate or pad the array to this size.

source property ProcessedData.pulse: pl.Pulse

The laser pulse used to process this data.

source property ProcessedData.register: pl.Register

The register to which the graph was compiled.

source method ProcessedData.draw_pulse()None

Draw the pulse on screen

source method ProcessedData.draw_register()None

Draw the register on screen

source method ProcessedData.draw_excitation()None

Draw an histogram for the excitation level on screen

source dist_excitation(state_dict: dict[str, int], size: int | None = None)np.ndarray

Calculates the distribution of excitation energies from a dictionary of bitstrings to their respective counts.

Parameters

  • size : int | None If specified, only keep size energy distributions in the output. Otherwise, keep all values.

Returns

  • np.ndarray A histogram of excitation energies. - index: an excitation level (i.e. a number of 1 bits in a bitstring) - value: normalized count of samples with this excitation level.

source save_dataset(dataset: list[ProcessedData], file_path: str)None

Saves a dataset to a JSON file.

Parameters

  • dataset : list[ProcessedData] The dataset to be saved, containing RegisterData instances.

  • file_path : str The path where the dataset will be saved as a JSON file.

Note

The data is stored in a format suitable for loading with load_dataset.

Returns

  • None None

source load_dataset(file_path: str)list[ProcessedData]

Loads a dataset from a JSON file.

Parameters

  • file_path : str The path to the JSON file containing the dataset.

Note

The data is loaded in the format that was used when saving with save_dataset.

Returns

  • list[ProcessedData] A list of ProcessedData instances, corresponding to the data stored in the JSON file.