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 ControlCell( qubit=Cell._replace_qubit(self.qubit, qubits), basis_change=tuple( op.with_qubits(*Cell._replace_qubits(op.qubits, qubits)) for op in self._basis_change), )