Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cirq-core/cirq/sim/state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ def density_matrix_of(self, qubits: list[cirq.Qid] | None = None) -> np.ndarray:
Raises:
ValueError: if the size of the state represents more than 25 qubits.
IndexError: if the indices are out of range for the number of qubits
corresponding to the state.
KeyError: if some of the qubits provided are not in the quantum state.
"""
return qis.density_matrix_from_state_vector(
self.state_vector(),
Expand All @@ -160,8 +159,7 @@ def bloch_vector_of(self, qubit: cirq.Qid) -> np.ndarray:
Raises:
ValueError: if the size of the state represents more than 25 qubits.
IndexError: if index is out of range for the number of qubits
corresponding to the state.
KeyError: if the specified qubit is not in the quantum state.
"""
return qis.bloch_vector_from_state_vector(
self.state_vector(), self.qubit_map[qubit], qid_shape=self._qid_shape
Expand Down
2 changes: 2 additions & 0 deletions cirq-core/cirq/sim/state_vector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ def test_step_result_bloch_vector():
bloch0 = np.array([0, 0, 1])
np.testing.assert_array_almost_equal(bloch1, step_result.bloch_vector_of(q1))
np.testing.assert_array_almost_equal(bloch0, step_result.bloch_vector_of(q0))
with pytest.raises(KeyError):
step_result.bloch_vector_of(cirq.LineQubit(2))


def test_factor_validation():
Expand Down
2 changes: 1 addition & 1 deletion examples/direct_fidelity_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _enumerate_all_from_stabilizer_bases(

@dataclass
class PauliTrace:
"""Holder of a description fo Pauli states.
"""Holder of a description of Pauli states.

This class contains the Pauli states as described on page 2 of: https://arxiv.org/abs/1104.3835
"""
Expand Down