<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wavefunction(self) -> pyquil.Wavefunction: """ Return the wavefunction of a completed program. """

        assert self.status == 'done'
        assert self._ket is not None
        wavefn = state_to_wavefunction(self._ket)
        return wavefn