observables_to_binary_matrix(observables, n_qubits=None, wire_map=None)[source]

Converts a list of Pauli words to the binary vector representation and yields a row matrix of the binary vectors.

The dimension of the binary vectors will be implied from the highest wire being acted on non-trivially by the Pauli words in observables.

  • observables (list[Union[Identity, PauliX, PauliY, PauliZ, Tensor, Prod, SProd]]) – the list of Pauli words

  • n_qubits (int) – number of qubits to specify dimension of binary vector representation

  • wire_map (dict) – dictionary containing all wire labels used in the Pauli words as keys, and unique integer labels as their values


a matrix whose rows are Pauli words in binary vector representation

Return type



>>> observables_to_binary_matrix([X(0) @ Y(2), Z(0) @ Z(1) @ Z(2)])
array([[1., 1., 0., 0., 1., 0.],
       [0., 0., 0., 1., 1., 1.]])