quara.protocol.qtomography.qtomography module

class QTomography(experiment, set_qoperations)[source]

Bases: object

initialize quantum tomography class.

To inherit from this class, set the following instance variables in the constructor of the subclass.

  • _num_variables: sum of the number of all variables.

Parameters
  • experiment (Experiment) – Experiment class used in quantum tomography.

  • set_qoperations (SetQOperations) – SetQOperations class used in quantum tomography.

abstract calc_prob_dist(qope, schedule_index)[source]

calculates a probability distribution.

this function must be implemented in the subclass.

Parameters
  • qope (QOperation) – QOperation to calculate a probability distribution.

  • schedule_index (int) – schedule index.

Returns

a probability distribution.

Return type

List[np.ndarray]

Raises

NotImplementedError – this function does not be implemented in the subclass.

abstract calc_prob_dists(qope)[source]

calculates probability distributions.

this function must be implemented in the subclass.

Parameters

qope (QOperation) – QOperation to calculate probability distributions.

Returns

probability distributions.

Return type

List[List[np.ndarray]]

Raises

NotImplementedError – this function does not be implemented in the subclass.

abstract func_prob_dist()[source]
abstract func_prob_dists()[source]
abstract generate_dataset(data_nums)[source]

Run all the schedules to caluclate the probability distribution and generate random data.

this function must be implemented in the subclass.

Parameters

data_nums (List[int]) – A list of the number of data to be generated in each schedule. This parameter should be a list of non-negative integers.

Returns

Generated dataset.

Return type

List[List[np.ndarray]]

Raises

NotImplementedError – this function does not be implemented in the subclass.

abstract generate_empi_dists(qoperation, num_sum)[source]

Generate empirical distributions using the data generated from probability distributions of all schedules.

this function must be implemented in the subclass.

Parameters
  • qoperation (QOperation) – QOperation to use to generate the experience distributions.

  • num_sum (int) – the number of data to use to generate the experience distributions for each schedule.

Returns

A list of tuples for the number of data and experience distributions for each schedules.

Return type

List[Tuple[int, np.ndarray]]

Raises

NotImplementedError – this function does not be implemented in the subclass.

abstract is_valid_experiment()[source]

returns whether the experiment is valid.

this function must be implemented in the subclass.

Returns

whether the experiment is valid.

Return type

bool

Raises

NotImplementedError – this function does not be implemented in the subclass.

property num_schedules: int

returns number of schedules.

Returns

number of schedules.

Return type

int

property num_variables: int

returns sum of the number of all variables.

Returns

sum of the number of all variables.

Return type

int

reset_seed(seed=None)[source]

reset new seed.

if seed is None, reset by seed which Experiment already has.

Parameters

seed (int, optional) – new seed, None by default.

Return type

None