cirq.pauli_expansion

cirq.pauli_expansion(val: Any, *, default: Union[cirq.value.linear_dict.LinearDict[str], TDefault] = cirq.LinearDict({}), atol: float = 1e-09) → Union[cirq.value.linear_dict.LinearDict[str], TDefault][source]

Returns coefficients of the expansion of val in the Pauli basis.

Parameters:
  • val – The value whose Pauli expansion is to returned.
  • default – Determines what happens when val does not have methods that allow Pauli expansion to be obtained (see below). If set, the value is returned in that case. Otherwise, TypeError is raised.
  • atol – Ignore coefficients whose absolute value is smaller than this.
Returns:

If val has a _pauli_expansion_ method, then its result is returned. Otherwise, if val has a small unitary then that unitary is expanded in the Pauli basis and coefficients are returned. Otherwise, if default is set to None or other value then default is returned. Otherwise, TypeError is raised.

Raises:
  • TypeError if val has none of the methods necessary to obtain its Pauli
  • expansion and no default value has been provided.