cirq.dirac_notation

Returns the state vector as a string in Dirac notation.

For example:

state_vector = np.array([1/np.sqrt(2), 1/np.sqrt(2)], dtype=np.complex64)
print(cirq.dirac_notation(state_vector))
0.71|0 + 0.71|1

state_vector A sequence representing a state vector in which the ordering mapping to qubits follows the standard Kronecker convention of numpy.kron (big-endian).
decimals How many decimals to include in the pretty print.
qid_shape specifies the dimensions of the qudits for the input state_vector. If not specified, qubits are assumed and the state_vector must have a dimension a power of two.

A pretty string consisting of a sum of computational basis kets and non-zero floats of the specified accuracy.

ValueError If there is a shape mismatch between state_vector and qid_shape. Otherwise, when qid_shape is not mentioned and length of state_vector is not a power of 2.