diff --git a/cirq-core/cirq/__init__.py b/cirq-core/cirq/__init__.py index 5b5491aae12..d68fc645b25 100644 --- a/cirq-core/cirq/__init__.py +++ b/cirq-core/cirq/__init__.py @@ -236,6 +236,7 @@ LinearCombinationOfOperations, MatrixGate, MixedUnitaryChannel, + M, measure, measure_each, measure_paulistring_terms, @@ -284,6 +285,7 @@ QubitOrder, QubitOrderOrList, QubitPermutationGate, + R, reset, reset_each, ResetChannel, diff --git a/cirq-core/cirq/ops/__init__.py b/cirq-core/cirq/ops/__init__.py index e11f67bbf15..516ebbbb505 100644 --- a/cirq-core/cirq/ops/__init__.py +++ b/cirq-core/cirq/ops/__init__.py @@ -41,6 +41,7 @@ phase_flip, PhaseDampingChannel, PhaseFlipChannel, + R, reset, reset_each, ResetChannel, @@ -126,6 +127,7 @@ from cirq.ops.matrix_gates import MatrixGate from cirq.ops.measure_util import ( + M, measure, measure_each, measure_paulistring_terms, diff --git a/cirq-core/cirq/ops/common_channels.py b/cirq-core/cirq/ops/common_channels.py index 5d78d183f77..7867b7e6cfa 100644 --- a/cirq-core/cirq/ops/common_channels.py +++ b/cirq-core/cirq/ops/common_channels.py @@ -775,10 +775,16 @@ def _json_dict_(self) -> Dict[str, Any]: def reset(qubit: 'cirq.Qid') -> raw_types.Operation: - """Returns a `cirq.ResetChannel` on the given qubit.""" + """Returns a `cirq.ResetChannel` on the given qubit. + + This can also be used with the alias `cirq.R`. + """ return ResetChannel(qubit.dimension).on(qubit) +R = reset + + def reset_each(*qubits: 'cirq.Qid') -> List[raw_types.Operation]: """Returns a list of `cirq.ResetChannel` instances on the given qubits.""" return [ResetChannel(q.dimension).on(q) for q in qubits] diff --git a/cirq-core/cirq/ops/measure_util.py b/cirq-core/cirq/ops/measure_util.py index f9521efb98d..49cf84a812f 100644 --- a/cirq-core/cirq/ops/measure_util.py +++ b/cirq-core/cirq/ops/measure_util.py @@ -115,7 +115,8 @@ def measure( ) -> raw_types.Operation: """Returns a single MeasurementGate applied to all the given qubits. - The qubits are measured in the computational basis. + The qubits are measured in the computational basis. This can also be + used with the alias `cirq.M`. Args: *target: The qubits that the measurement gate should measure. @@ -159,6 +160,9 @@ def measure( return MeasurementGate(len(targets), key, invert_mask, qid_shape, confusion_map).on(*targets) +M = measure + + @overload def measure_each( *qubits: raw_types.Qid, key_func: Callable[[raw_types.Qid], str] = str