def generate_param_args_list()

in orbit/utils/params_tuning.py [0:0]


def generate_param_args_list(param_grid):
    """An utils similar to sci-kit learn package to generate combinations of args based on spaces of parameters
    provided from users in a dictionary of list format.


    Parameters
    ----------
    param_grid: dict of list
    dictionary where key represents the arg and value represents the list of values proposed for the grid

    Returns
    -------
    list of dict
    the iterated products of all combinations of params generated based on the input param grid
    """

    # an internal function to mimic the ParameterGrid from scikit-learn

    def _yield_param_grid(param_grid):
        if not isinstance(param_grid, (Mapping, Iterable)):
            raise TypeError(
                "Parameter grid is not a dict or a list ({!r})".format(param_grid)
            )

        if isinstance(param_grid, Mapping):
            # wrap dictionary in a singleton list to support either dict
            # or list of dicts
            param_grid = [param_grid]

        for p in param_grid:
            # Always sort the keys of a dictionary, for reproducibility
            items = sorted(p.items())
            if not items:
                yield {}
            else:
                keys, values = zip(*items)
                for v in product(*values):
                    params = dict(zip(keys, v))
                    yield params

    return list(_yield_param_grid(param_grid))