from typing import OrderedDict


def copy_items(arg_dict, argnames):
    """Copy a set of parameters tuples to an smaller dictionary

    Parameters
    ----------
    arg_dict : `dict`
        The dictionary mapping name to (type, default, helpstring) tuple
    argnames : `list`
        List of keys to copy to the output dictionary

    Returns
    -------
    outdict : `dict`
        Dictionary with only the arguments we have selected
    """
    outdict = OrderedDict()
    for argname in argnames:
        if argname not in arg_dict:
            raise KeyError("Argument %s is not defined in dictionary" % argname)
        outdict[argname] = arg_dict[argname]
    return outdict