示例#1
0
    def controlled_by(self, *control_qubits: Qid) -> 'Operation':
        """Returns a controlled version of this operation.

        Args:
            control_qubits: Qubits to control the operation by. Required.
        """
        # Avoids circular import.
        from cirq.ops import ControlledOperation
        if len(control_qubits) == 0:
            return self
        return ControlledOperation(control_qubits, self)
示例#2
0
    def controlled_by(self, *control_qubits: Qid) -> 'Operation':
        """Returns a controlled version of this operation.

        Args:
            control_qubits: Qubits to control the operation by. Required.
        """
        # Avoids circular import.
        from cirq.ops import ControlledOperation
        if control_qubits is None or len(control_qubits) is 0:
            raise ValueError(
                "Can't get controlled operation without control qubit. Op: {}"
                .format(repr(self)))
        else:
            return ControlledOperation(control_qubits, self)
示例#3
0
文件: raw_types.py 项目: jshede/Cirq
    def controlled_by(
        self,
        *control_qubits: Qid,
        control_values: Optional[Sequence[Union[int, Collection[int]]]] = None
    ) -> 'Operation':
        """Returns a controlled version of this operation.

        Args:
            control_qubits: Qubits to control the operation by. Required.
        """
        # Avoids circular import.
        from cirq.ops import ControlledOperation
        if len(control_qubits) == 0:
            return self
        return ControlledOperation(control_qubits, self, control_values)
示例#4
0
    def controlled_by(
        self,
        *control_qubits: Qid,
        control_values: Optional[Sequence[Union[int, Collection[int]]]] = None
    ) -> 'Operation':
        """Returns a controlled version of this operation.

        Args:
            control_qubits: Qubits to control the operation by. Required.
            control_values: For which control qubit values to apply the
                operation.  A sequence of the same length as `control_qubits`
                where each entry is an integer (or set of integers)
                corresponding to the qubit value (or set of possible values)
                where that control is enabled.  When all controls are enabled,
                the operation is applied.  If unspecified, control values
                default to 1.
        """
        # Avoids circular import.
        from cirq.ops import ControlledOperation
        if len(control_qubits) == 0:
            return self
        return ControlledOperation(control_qubits, self, control_values)