diff --git a/cirq-core/cirq/devices/grid_qubit.py b/cirq-core/cirq/devices/grid_qubit.py index 5a54c8fc1d4..236819b7511 100644 --- a/cirq-core/cirq/devices/grid_qubit.py +++ b/cirq-core/cirq/devices/grid_qubit.py @@ -285,7 +285,7 @@ def rect(rows: int, cols: int, top: int = 0, left: int = 0, *, dimension: int) - @staticmethod def from_diagram(diagram: str, dimension: int) -> list[GridQid]: - """Parse ASCII art device layout into a device. + r"""Parse ASCII art device layout into a device. As an example, the below diagram will create a list of GridQid in a pyramid structure. @@ -322,7 +322,7 @@ def from_diagram(diagram: str, dimension: int) -> list[GridQid]: a row. Alphanumeric characters are assigned as qid. Dots ('.'), dashes ('-'), and spaces (' ') are treated as empty locations in the grid. If diagram has characters other - than alphanumerics, spacers, and newlines ('\\n'), an error will + than alphanumerics, spacers, and newlines ('\n'), an error will be thrown. The top-left corner of the diagram will be have coordinate (0, 0). @@ -439,7 +439,7 @@ def rect(rows: int, cols: int, top: int = 0, left: int = 0) -> list[GridQubit]: @staticmethod def from_diagram(diagram: str) -> list[GridQubit]: - """Parse ASCII art into device layout info. + r"""Parse ASCII art into device layout info. As an example, the below diagram will create a list of GridQubit in a pyramid structure. @@ -476,7 +476,7 @@ def from_diagram(diagram: str) -> list[GridQubit]: a row. Alphanumeric characters are assigned as qid. Dots ('.'), dashes ('-'), and spaces (' ') are treated as empty locations in the grid. If diagram has characters other - than alphanumerics, spacers, and newlines ('\\n'), an error will + than alphanumerics, spacers, and newlines ('\n'), an error will be thrown. The top-left corner of the diagram will be have coordinate (0,0). @@ -503,7 +503,7 @@ def _json_dict_(self) -> dict[str, Any]: def _ascii_diagram_to_coords(diagram: str) -> list[tuple[int, int]]: - """Parse ASCII art device layout into info about qids coordinates + r"""Parse ASCII art device layout into info about qids coordinates Args: diagram: String representing the qid layout. Each line represents diff --git a/cirq-core/cirq/linalg/decompositions.py b/cirq-core/cirq/linalg/decompositions.py index e27055c9480..4a5f0d6e8fa 100644 --- a/cirq-core/cirq/linalg/decompositions.py +++ b/cirq-core/cirq/linalg/decompositions.py @@ -243,7 +243,7 @@ def so4_to_magic_su2s( @value.value_equality(approximate=True) class AxisAngleDecomposition: - """Represents a unitary operation as an axis, angle, and global phase. + r"""Represents a unitary operation as an axis, angle, and global phase. The unitary $U$ is decomposed as follows: diff --git a/cirq-core/cirq/ops/named_qubit.py b/cirq-core/cirq/ops/named_qubit.py index 67dd8ad0159..cd67451b1e2 100644 --- a/cirq-core/cirq/ops/named_qubit.py +++ b/cirq-core/cirq/ops/named_qubit.py @@ -148,7 +148,7 @@ def __str__(self) -> str: @staticmethod def range(*args, prefix: str, dimension: int) -> list[NamedQid]: - """Returns a range of ``NamedQid``\\s. + """Returns a range of ``NamedQid``s. The range returned starts with the prefix, and followed by a qid for each number in the range, e.g.: @@ -166,7 +166,7 @@ def range(*args, prefix: str, dimension: int) -> list[NamedQid]: dimension: The dimension of the qid's Hilbert space, i.e. the number of quantum levels. Returns: - A list of ``NamedQid``\\s. + A list of ``NamedQid``s. """ return [NamedQid(f"{prefix}{i}", dimension=dimension) for i in range(*args)] diff --git a/cirq-core/cirq/vis/density_matrix.py b/cirq-core/cirq/vis/density_matrix.py index d64c43bdf7f..b8264baaced 100644 --- a/cirq-core/cirq/vis/density_matrix.py +++ b/cirq-core/cirq/vis/density_matrix.py @@ -84,7 +84,7 @@ def plot_density_matrix( show_text: bool = False, title: str | None = None, ) -> plt.Axes: - """Generates a plot for a given density matrix. + r"""Generates a plot for a given density matrix. 1. Each entry of the density matrix, a complex number, is plotted as an Argand Diagram where the partially filled red circle represents the magnitude diff --git a/examples/stabilizer_code.py b/examples/stabilizer_code.py index acddb5eec02..0605fb6d8d7 100644 --- a/examples/stabilizer_code.py +++ b/examples/stabilizer_code.py @@ -322,7 +322,7 @@ def correct(self, qubits: list[cirq.Qid], ancillas: list[cirq.Qid]) -> cirq.Circ return circuit def decode(self, qubits: list[cirq.Qid], ancillas: list[cirq.Qid], state_vector) -> list[int]: - """Computes the output of the circuit by projecting onto the \bar{Z}. + r"""Computes the output of the circuit by projecting onto the \bar{Z}. Args: qubits: the qubits where the (now corrected) code words are stored. diff --git a/pyproject.toml b/pyproject.toml index 73c30646783..27078a8fc69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,7 @@ select = [ # pylint expression-not-assigned, pointless-exception-statement, # pointless-statement, pointless-string-statement "B033", # duplicate-value, pylint duplicate-value + "D301", # escape-sequence-in-docstring "D419", # empty-docstring, pylint empty-docstring "E402", # module-import-not-at-top-of-file, pylint wrong-import-position "E501", # line-too-long, pylint line-too-long