Skip to content

Commit cc9865c

Browse files
authored
Fix docstring for cirq.map_operations (quantumlib#5849)
* Fix docstrings for cirq.map_operations
1 parent e364769 commit cc9865c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

cirq/transformers/transformer_primitives.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ def map_operations(
112112
raise_if_add_qubits=True,
113113
tags_to_ignore: Sequence[Hashable] = (),
114114
) -> CIRCUIT_TYPE:
115-
"""Applies local transformations on operations, by calling `map_func(op)` for each op.
115+
"""Applies local transformations, by calling `map_func(op, moment_index)` for each operation.
116116
117-
By default, the function assumes `issubset(qubit_set(map_func(op)), op.qubits)` is True.
117+
By default, the function assumes `issubset(qubit_set(map_func(op, moment_index)), op.qubits)` is
118+
True.
118119
119120
Args:
120121
circuit: Input circuit to apply the transformations on. The input circuit is not mutated.
@@ -125,14 +126,14 @@ def map_operations(
125126
subsequently be used to unroll the mapped circuit operation.
126127
deep: If true, `map_func` will be recursively applied to circuits wrapped inside
127128
any circuit operations contained within `circuit`.
128-
raise_if_add_qubits: Set to True by default. If True, raises ValueError if `map_func(op)`
129-
adds operations on qubits outside of `op.qubits`.
129+
raise_if_add_qubits: Set to True by default. If True, raises ValueError if
130+
`map_func(op, idx)` adds operations on qubits outside of `op.qubits`.
130131
tags_to_ignore: Sequence of tags which should be ignored while applying `map_func` on
131132
tagged operations -- i.e. `map_func(op, idx)` will be called only for operations that
132133
satisfy `set(op.tags).isdisjoint(tags_to_ignore)`.
133134
134135
Raises:
135-
ValueError if `issubset(qubit_set(map_func(op)), op.qubits) is False` and
136+
ValueError if `issubset(qubit_set(map_func(op, idx)), op.qubits) is False` and
136137
`raise_if_add_qubits is True`.
137138
138139
Returns:
@@ -180,8 +181,8 @@ def map_operations_and_unroll(
180181
map_func: Mapping function from (cirq.Operation, moment_index) to a cirq.OP_TREE.
181182
deep: If true, `map_func` will be recursively applied to circuits wrapped inside
182183
any circuit operations contained within `circuit`.
183-
raise_if_add_qubits: Set to True by default. If True, raises ValueError if `map_func(op)`
184-
adds operations on qubits outside of `op.qubits`.
184+
raise_if_add_qubits: Set to True by default. If True, raises ValueError if
185+
`map_func(op, idx)` adds operations on qubits outside `op.qubits`.
185186
tags_to_ignore: Sequence of tags which should be ignored while applying `map_func` on
186187
tagged operations -- i.e. `map_func(op, idx)` will be called only for operations that
187188
satisfy `set(op.tags).isdisjoint(tags_to_ignore)`.

0 commit comments

Comments
 (0)