quara.objects.circuit module

class Circuit(num, mode='qubit')[source]

Bases: object

Constructor

Parameters
  • num (int) – number of qubits in a quantum circuit.

  • mode (str) – currently supports only “qubit”.

add_gate(ids, gate=None, gate_name=None)[source]

Adds a quantum gate to the circuit.

Parameters
  • ids (List[int]) – List of indices of qubits which the gate will be applied on.

  • gate (Gate) – optional. Either gate or gate_name must be specified. A gate object that will be added to a circuit.

  • gate_name (str) – optional. Either gate or gate_name must be specified. A name of a gate object that will be added to a circuit. Valid gate names can be listed by calling get_gate_names().

Returns

Number of distributions match to the number of measurement operators in a quantum circuit.

Return type

List[MultinomialDistribution]

add_mprocess(ids, mprocess=None, mprocess_name=None)[source]

Adds a mprocess to the circuit.

Parameters
  • ids (List[int]) – List of indices of qubits which the measurement will be applied on.

  • mprocess (MProcess) – optional. Either mprocess or mprocess_name must be specified. A mprocess object that will be added to a circuit.

  • mprocess_name (str) – optional. Either mprocess or mprocess_name must be specified. A name of a mprocess that will be added to a circuit. Valid mprocess names can be listed by calling get_mprocess_names_type1() and get_mprocess_names_type2().

Returns

Number of distributions match to the number of measurement operators in a quantum circuit.

Return type

List[MultinomialDistribution]

run(num_shots, initial_state_mode=None, initial_states=None)[source]

Runs the quantum circuit with given initial state and number of shots.

Parameters
  • num_shots (int) – number of shots to be performed.

  • initial_state_mode (Optional[str]) – optional. Either initial_state_mode or initial_states must be specified. only “all_zero” is available for now. “all_zero” will create a state where all qubits are “z0”.

  • initial_state (str) – optional. Either mprocess or mprocess_name must be specified. A name of a mprocess that will be added to a circuit. Valid mprocess names can be listed by calling get_mprocess_names_type1() and get_mprocess_names_type2().

  • initial_states (Optional[List[quara.objects.state.State]]) –

Returns

Number of distributions match to the number of measurement operators in a quantum circuit.

Return type

List[MultinomialDistribution]

class CircuitResult(circuit_overview)[source]

Bases: object

Class to manage experiment settings This class is not limited to tomography, but deals with general quantum circuits.

Constructor

Parameters

circuit_overview (List[dict]) – Overview of a quantum circuit which contains dictionaries of quantum objects. see Circuit class for more information.

append_raw_output(raw_output)[source]

Appends raw output of a quantum circuit into an internal array.

Parameters

raw_output (List[int]) – List of readouts of the measurements in a circuit.

Returns

Return type

None

calc_empi_dist()[source]

Calculates empirical distributions based on raw readout data for every measurement operator in a quantum circuit.

Parameters

None

Returns

Number of distributions match to the number of measurement operators in a quantum circuit.

Return type

List[MultinomialDistribution]

property empi_dists
property raw_result