from warnings import warn


def _remove_forbidden_op_kwds(op_method, op_kwds):
    """
    Remove forbidden optimization keywords.

    :param op_method:
        The optimization algorithm to use.

    :param op_kwds:
        Optimization keywords.

    :returns:
        `None`. The dictionary of `op_kwds` will be updated.
    """
    all_allowed_keys = dict(
        l_bfgs_b=("x0", "args", "bounds", "m", "factr", "pgtol", "epsilon", 
            "iprint", "maxfun", "maxiter", "disp", "callback", "maxls"),
        powell=("x0", "args", "xtol", "ftol", "maxiter", "maxfun", 
            "full_output", "disp", "retall", "callback", "initial_simplex"))

    forbidden_keys = set(op_kwds).difference(all_allowed_keys[op_method])
    if forbidden_keys:
        warn("Ignoring forbidden optimization keywords for {}: {}"\
            .format(op_method, ", ".join(forbidden_keys)))
        for key in forbidden_keys:
            del op_kwds[key]

    return None