code: def endpoints_minima(self, slope_cutoff=5e-3):
          
          energies = self.energies
          try:
              sp = self.spline()
          except:
              print("Energy spline failed.")
              return None
          der = sp.derivative()
          der_energies = der(range(len(energies)))
          return {"polar": abs(der_energies[-1]) <= slope_cutoff,
                  "nonpolar": abs(der_energies[0]) <= slope_cutoff}
docs: Test if spline endpoints are at minima for a given slope cutoff.