Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docstring for cirq.map_operations #5849

Merged
merged 14 commits into from
Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions cirq-core/cirq/transformers/transformer_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ def map_operations(
raise_if_add_qubits=True,
tags_to_ignore: Sequence[Hashable] = (),
) -> CIRCUIT_TYPE:
"""Applies local transformations on operations, by calling `map_func(op)` for each op.
"""Applies local transformations, by calling `map_func(op, moment_index)` for each operation.

By default, the function assumes `issubset(qubit_set(map_func(op)), op.qubits)` is True.
By default, the function assumes `issubset(qubit_set(map_func(op, moment_index)), op.qubits)` is
True.

Args:
circuit: Input circuit to apply the transformations on. The input circuit is not mutated.
Expand All @@ -125,14 +126,14 @@ def map_operations(
subsequently be used to unroll the mapped circuit operation.
deep: If true, `map_func` will be recursively applied to circuits wrapped inside
any circuit operations contained within `circuit`.
raise_if_add_qubits: Set to True by default. If True, raises ValueError if `map_func(op)`
adds operations on qubits outside of `op.qubits`.
raise_if_add_qubits: Set to True by default. If True, raises ValueError if
`map_func(op, idx)` adds operations on qubits outside of `op.qubits`.
tags_to_ignore: Sequence of tags which should be ignored while applying `map_func` on
tagged operations -- i.e. `map_func(op, idx)` will be called only for operations that
satisfy `set(op.tags).isdisjoint(tags_to_ignore)`.

Raises:
ValueError if `issubset(qubit_set(map_func(op)), op.qubits) is False` and
ValueError if `issubset(qubit_set(map_func(op, idx)), op.qubits) is False` and
`raise_if_add_qubits is True`.

Returns:
Expand Down Expand Up @@ -180,8 +181,8 @@ def map_operations_and_unroll(
map_func: Mapping function from (cirq.Operation, moment_index) to a cirq.OP_TREE.
deep: If true, `map_func` will be recursively applied to circuits wrapped inside
any circuit operations contained within `circuit`.
raise_if_add_qubits: Set to True by default. If True, raises ValueError if `map_func(op)`
adds operations on qubits outside of `op.qubits`.
raise_if_add_qubits: Set to True by default. If True, raises ValueError if
`map_func(op, idx)` adds operations on qubits outside `op.qubits`.
tags_to_ignore: Sequence of tags which should be ignored while applying `map_func` on
tagged operations -- i.e. `map_func(op, idx)` will be called only for operations that
satisfy `set(op.tags).isdisjoint(tags_to_ignore)`.
Expand Down