pygsti.extras.idletomography.pauliobjs

Pauli state/operation/outcome objects for Idle Tomography

Module Contents

Classes

NQOutcome

A string of 0's and 1's representing a definite outcome in the Z-basis.

NQPauliState

A N-qubit state that is the tensor product of N

NQPauliOp

A N-qubit pauli operator, consisting of

Functions

_commute_parity(pauli1, pauli2)

1 if pauli1 commutes w/pauli2, -1 if they anticommute

pygsti.extras.idletomography.pauliobjs._commute_parity(pauli1, pauli2)

1 if pauli1 commutes w/pauli2, -1 if they anticommute

class pygsti.extras.idletomography.pauliobjs.NQOutcome(string_rep)

Bases: object

A string of 0’s and 1’s representing a definite outcome in the Z-basis.

classmethod weight_1_string(cls, n, i)

creates a n-bit string with a 1 in location i.

classmethod weight_2_string(cls, n, i, j)

creates a n-bit string with 1s in locations i and j.

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__eq__(self, other)

Return self==value.

__hash__(self)

Return hash(self).

flip(self, *indices)

Flip “0” <-> “1” at any number of indices. This function takes a variable number of integer arguments specifying the qubit indices whose value should be flipped.

Returns

NQOutcome – A new outcome object with flipped bits.

class pygsti.extras.idletomography.pauliobjs.NQPauliState(string_rep, signs=None)

Bases: object

A N-qubit state that is the tensor product of N 1-qubit Pauli eigenstates. These can be represented as a string of Xs, Ys and Zz (but not Is) each with a +/- sign indicating which of the two eigenstates is meant.

A NQPauliState object can also be used to represent a POVM whose effects are the projections onto the 2^N tensor products of (the given) Pauli eigenstates. The +/- sign in this case indicates which eigenstate is equated with the “0” (vs “1”) outcome.

__len__(self)
__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__eq__(self, other)

Return self==value.

__hash__(self)

Return hash(self).

to_circuit(self, pauli_basis_dict)

Convert this Pauli basis state or measurement to a fiducial operation sequence.

When the returned operation sequence follows a preparation in the |0…0> Z-basis state or is followed by a Z-basis measurement (with all “+” signs), then the Pauli state preparation or measurement described by this object will be performed.

Parameters

pauli_basis_dict (dict) – A dictionary w/keys like “+X” or “-Y” and values that are tuples of gate names (not labels, which include qubit or other state-space designations), e.g. (“Gx”,”Gx”). This dictionary describes how to prepare or measure in Pauli bases.

Returns

Circuit

class pygsti.extras.idletomography.pauliobjs.NQPauliOp(string_rep, sign=1)

Bases: object

A N-qubit pauli operator, consisting of a 1-qubit Pauli operation on each qubits.

classmethod weight_1_pauli(cls, n, i, pauli)

Creates a n-qubit Pauli operator with the Pauli indexed by pauli in location i.

Parameters
  • n (int) – The number of qubits

  • i (int) – The index of the single non-trivial Pauli operator.

  • pauli (int) – An integer 0 <= P <= 2 indexing the non-trivial Pauli at location i as follows: 0=’X’, 1=’Y’, 2=’Z’.

Returns

NQPauliOp

classmethod weight_2_pauli(cls, n, i, j, pauli1, pauli2)

Creates a n-qubit Pauli operator with the Paulis indexed by pauli1 and pauli2 in locations i and j respectively.

Parameters
  • n (int) – The number of qubits

  • i (int) – The indices of the non-trivial Pauli operators.

  • j (int) – The indices of the non-trivial Pauli operators.

  • pauli1 (int) – Integers 0 <= pauli <= 2 indexing the non-trivial Paulis at locations i and j, respectively, as follows: 0=’X’, 1=’Y’, 2=’Z’.

  • pauli2 (int) – Integers 0 <= pauli <= 2 indexing the non-trivial Paulis at locations i and j, respectively, as follows: 0=’X’, 1=’Y’, 2=’Z’.

Returns

NQPauliOp

__len__(self)
__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__eq__(self, other)

Return self==value.

__hash__(self)

Return hash(self).

subpauli(self, indices)

Returns a new NQPauliOp object which sets all (1-qubit) operators to “I” except those in indices, which remain as they are in this object.

Parameters

indices (iterable) – A sequence of integer indices between 0 and N-1, where N is the number of qubits in this pauli operator.

Returns

NQPauliOp

dot(self, other)

Computes the Hilbert-Schmidt dot product (normed to 1) between this Pauli operator and other.

Parameters

other (NQPauliOp) – The other operator to take a dot product with.

Returns

integer – Either 0, 1, or -1.

statedot(self, state)

Computes a dot product between state and this operator. (note that an X-basis ‘+’ state is represented by (I+X) not just X)

Parameters

state (NQPauliState) –

Returns

int

commuteswith(self, other)

Determine whether this operator commutes (or anticommutes) with other.

Parameters

other (NQPauliOp) –

Returns

bool

icommutator_over_2(self, other)

Compute i[self, other]/2 where [,] is the commutator.

Parameters

other (NQPauliOp or NQPauliState) – The operator to take a commutator with. A NQPauliState is treated as an operator (i.e. ‘X’ basis state => ‘X’ Pauli operation) with sign given by the product of its 1-qubit basis signs.

Returns

NQPauliOp