HShots#

class hugr.qsystem.result.HShots(**kwargs)[source]#

Bases: QsysResult

Deprecated alias for QsysResult.

Methods

collated_counts

Calculate counts of bit strings for each tag by collating across shots using QsysResult.tag_collated_shots.

collated_shots

For each shot generate a dictionary of tags to collated data.

register_bitstrings

Convert results to a dictionary from register name to list of bitstrings over the shots.

register_counts

Convert results to a dictionary of register counts.

to_pytket

Convert results to a pytket BackendResult.

Attributes

results

collated_counts() Counter[tuple[tuple[str, str], ...]]#

Calculate counts of bit strings for each tag by collating across shots using QsysResult.tag_collated_shots. Each result entry per shot is seen to be appending to the bitstring for that tag.

If the result value is a list, it is flattened and appended to the bitstring.

Example

>>> shots = [QsysShot([("a", 1), ("a", 0)]), QsysShot([("a", [0, 1])])]
>>> res = QsysResult(shots)
>>> res.collated_counts()
Counter({(('a', '10'),): 1, (('a', '01'),): 1})
Raises:

ValueError – If any value is a float.

collated_shots() list[dict[str, list[int | float | bool | list[int | float | bool]]]]#

For each shot generate a dictionary of tags to collated data.

register_bitstrings(strict_names: bool = False, strict_lengths: bool = False) dict[str, list[str]]#

Convert results to a dictionary from register name to list of bitstrings over the shots.

Parameters:
  • strict_names – Whether to enforce that all shots have the same registers.

  • strict_lengths – Whether to enforce that all register bitstrings have the same length.

register_counts(strict_names: bool = False, strict_lengths: bool = False) dict[str, Counter[str]]#

Convert results to a dictionary of register counts.

Returns:

A dictionary where the keys are the register names and the values are the counts of the register bitstrings.

Return type:

dict

to_pytket() BackendResult#

Convert results to a pytket BackendResult.

Returns:

A BackendResult object with the shots.

Return type:

BackendResult

Raises:
  • ImportError – If pytket is not installed.

  • ValueError – If a register’s bitstrings have different lengths or not all

  • registers are present in all shots.