import warnings
import importlib


def loadpes(pesname):
    """
    Load built-in PES.

    Parameters
    ----------
    pesname : str
        PES name.

    Returns
    -------
    pes : DFun
        The PES as a DFun object.

    """
    
    warnings.warn("loadpes is deprecated. Import directly from nitrogen.pes.library modules",
                  DeprecationWarning)
    
    try : 
        mod = importlib.import_module("nitrogen.pes.library." + pesname)
    except ModuleNotFoundError:
        raise ValueError("PES name is not recognized.")
        
        
    return mod.PES