Beispiel #1
0
    def _value_equality_values_(self):
        if len(self._qubit_pauli_map) == 1 and self.coefficient == 1:
            q, p = list(self._qubit_pauli_map.items())[0]
            return gate_operation.GateOperation(p,
                                                [q])._value_equality_values_()

        return (frozenset(self._qubit_pauli_map.items()), self._coefficient)
Beispiel #2
0
    def on(self, *qubits: raw_types.Qid) -> raw_types.Operation:
        """Returns an application of this gate to the given qubits.

        Args:
            *qubits: The collection of qubits to potentially apply the gate to.
        """
        maybe_rekeyed_gate = self.with_key(self.mkey.with_qubits(qubits))
        return gate_operation.GateOperation(maybe_rekeyed_gate, list(qubits))
Beispiel #3
0
    def on(self, *qubits: Qid) -> 'Operation':
        """Returns an application of this gate to the given qubits.

        Args:
            *qubits: The collection of qubits to potentially apply the gate to.
        """
        # Avoids circular import.
        from cirq.ops import gate_operation
        return gate_operation.GateOperation(self, list(qubits))
Beispiel #4
0
    def on(self, *qubits: Qid) -> 'gate_operation.GateOperation':
        """Returns an application of this gate to the given qubits.

        Args:
            *qubits: The collection of qubits to potentially apply the gate to.
        """
        # Avoids circular import.
        from cirq.ops import gate_operation

        if len(qubits) == 0:
            raise ValueError(
                "Applied a gate to an empty set of qubits. Gate: {}".format(
                    repr(self)))
        return gate_operation.GateOperation(self, list(qubits))