def neighbors_of(self, qubit: LineQubit): """Returns the qubits that the given qubit can interact with.""" possibles = [ LineQubit(qubit.x + 1), LineQubit(qubit.x - 1), ] return [e for e in possibles if e in self.qubits]
def at(self, position: int) -> Optional[LineQubit]: """Returns the qubit at the given position, if there is one, else None. """ q = LineQubit(position) return q if q in self.qubits else None