code: def energy(self, hamiltonian):
          r
          from ..potential import PotentialBase
          if isinstance(hamiltonian, PotentialBase):
              from ..potential import Hamiltonian
  
              warnings.warn("This function now expects a `Hamiltonian` instance "
                            "instead of  a `PotentialBase` subclass instance. If "
                            "you are using a static reference frame, you just "
                            "need to pass your potential object in to the "
                            "Hamiltonian constructor to use, e.g., "
                            "Hamiltonian(potential).", DeprecationWarning)
  
              hamiltonian = Hamiltonian(hamiltonian)
  
          return hamiltonian(self)
docs: r"""
          The total energy *per unit mass* (e.g., kinetic + potential):
  
          Parameters
          ----------
          hamiltonian : `gala.potential.Hamiltonian`
              The Hamiltonian object to evaluate the energy.
  
          Returns
          -------
          E : :class:`~astropy.units.Quantity`
              The total energy.