Convert a QuantumFlow state to a pyQuil Wavefunction

def state_to_wavefunction(state: State) -> pyquil.Wavefunction:
    """Convert a QuantumFlow state to a pyQuil Wavefunction"""
    # TODO: qubits?
    amplitudes = state.vec.asarray()

    # pyQuil labels states backwards.
    amplitudes = amplitudes.transpose()
    amplitudes = amplitudes.reshape([amplitudes.size])
    return pyquil.Wavefunction(amplitudes)