def with_line_qubits_mapped_to(self, qubits: List['cirq.Qid']) -> 'Cell': return ParityControlCell( qubits=Cell._replace_qubits(self.qubits, qubits), basis_change=tuple( op.with_qubits(*Cell._replace_qubits(op.qubits, qubits)) for op in self._basis_change), )
def with_line_qubits_mapped_to(self, qubits: List['cirq.Qid']) -> 'Cell': return ArithmeticCell(identifier=self.identifier, target=Cell._replace_qubits(self.target, qubits), inputs=[ e if e is None or isinstance(e, int) else Cell._replace_qubits(e, qubits) for e in self.inputs ])
def with_line_qubits_mapped_to(self, qubits: List['cirq.Qid']) -> 'Cell': return InputRotationCell( self.identifier, None if self.register is None else Cell._replace_qubits( self.register, qubits), self.base_operation.with_qubits( *Cell._replace_qubits(self.base_operation.qubits, qubits)), exponent_sign=self.exponent_sign)
def test_cell_replace_utils(): a, b, c = cirq.NamedQubit.range(3, prefix='q') assert Cell._replace_qubit(cirq.LineQubit(1), [a, b, c]) == b with pytest.raises(ValueError, match='only map from line qubits'): _ = Cell._replace_qubit(cirq.GridQubit(0, 0), [a, b, c]) with pytest.raises(ValueError, match='not in range'): _ = Cell._replace_qubit(cirq.LineQubit(-1), [a, b, c]) with pytest.raises(ValueError, match='not in range'): _ = Cell._replace_qubit(cirq.LineQubit(999), [a, b, c])
def with_line_qubits_mapped_to(self, qubits: List['cirq.Qid']) -> 'Cell': return InputCell(qubits=Cell._replace_qubits(self.qubits, qubits), letter=self.letter)
def with_line_qubits_mapped_to(self, qubits: List['cirq.Qid']) -> 'Cell': return SwapCell( qubits=Cell._replace_qubits(self._qubits, qubits), controls=Cell._replace_qubits(self._controls, qubits), )