<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_energy_range(self, logemin, logemax):
 """Set the energy range of the analysis. Parameters logemin: float Lower end of energy range in log10(E/MeV). logemax : float Upper end of energy range in log10(E/MeV). """


        if logemin is None:
            logemin = self.log_energies[0]

        if logemax is None:
            logemax = self.log_energies[-1]

        imin = int(utils.val_to_edge(self.log_energies, logemin)[0])
        imax = int(utils.val_to_edge(self.log_energies, logemax)[0])

        if imin - imax == 0:
            imin = int(len(self.log_energies) - 1)
            imax = int(len(self.log_energies) - 1)

        klims = self.like.logLike.klims()
        if imin != klims[0] or imax != klims[1]:
            self.like.selectEbounds(imin, imax)

        return np.array([self.log_energies[imin], self.log_energies[imax]])