qubiter.device_specific.RigettiTools module¶

class
qubiter.device_specific.RigettiTools.
RigettiTools
[source]¶ Bases:
object
This class has no constructor. It consists of static methods that facilitate the interaction between Qubiter and PyQuil and the Rigetti Cloud.

add_xy_meas_coda_to_program
(bit_pos_to_xy_str)[source]¶ This method adds a “coda” (tail ending) to prog using data in bit_pos_to_xy_str to determine what coda will be.
Parameters:  prog (Program) –
 bit_pos_to_xy_str (dict[int, str]) –
Returns: Return type: None

static
obs_vec_from_bitstrings
(bitstrings, num_qbits, bs_is_array)[source]¶ This method converts a PyQuil bitstrings into a Qubiter observation vector which it then returns.
Qubiter likes to state the results of an experiment repeated num_shots (aka num_samples) times by what it calls an observation vector. An obs vec is a 1dim array, num_shots long, whose entries are integers which are the decimal representation of a string, num_qbits long, of zeros and ones. This string of zeros and ones gives the state of each qubit in the ZL convention
PyQuil likes to state the results of an experiment repeated num_shots times by what it calls bitstrings. A bitstrings is a dict that maps qubit number to a 1dim array, num_shots long, of zeros and ones. Here is an example:
# [1]: # # bitstrings = qc.run_and_measure(program, trials=10) # bitstrings # # [2]: # # {0: array([1, 0, 0, 1, 1, 1, 1, 0, 1, 0]), # 1: array([1, 0, 0, 1, 1, 1, 1, 0, 1, 0]), # 2: array([1, 0, 0, 1, 1, 1, 1, 0, 1, 0])}
However, qc.run() returns a numpy array of zeros and ones and shape (num_shots, num_qbits), formed from the bitstrings dict just described. If bs_is_array=False, we assume the input bitstrings is a dict, and if True, we assume it is an array.
Parameters:  bitstrings (dict[int, np.ndarray]) –
 num_qbits (int) –
 bs_is_array (bool) – stands for: bitstrings is array
Returns: shape = (num_shots,)
Return type: np.ndarray
