def from_named_qubit(qubit: cirq.NamedQubit) -> 'AspenQubit':
        """Converts `cirq.NamedQubit` to `AspenQubit`.

        Returns:
            The equivalent AspenQubit.

        Raises:
            ValueError: NamedQubit cannot be converted to AspenQubit.
            UnsupportedQubit: If the supplied qubit is not a named qubit with an octagonal
                index.
        """
        try:
            index = int(qubit.name)
            return AspenQubit.from_aspen_index(index)
        except ValueError:
            raise UnsupportedQubit('Aspen devices only support named qubits by octagonal index')
Converts `cirq.NamedQubit` to `AspenQubit`.

        Returns:
            The equivalent AspenQubit.

        Raises:
            ValueError: NamedQubit cannot be converted to AspenQubit.
            UnsupportedQubit: If the supplied qubit is not a named qubit with an octagonal
                index.
        
cirq-rigetti/cirq_rigetti/aspen_device.py