def values_to_params(param_values, param_space):
    """
    We don't need to optimize parameters with a single value in their domain so we filter
    them out with params to skopt and convert back to configuration using this method

    Args:
        param_values: dict {param_name: value}
        param_space: rest of the parameter space used to complete this configuration

    """
    cfg = {}
    for param_name in param_space.param_names():
        if param_name in param_values:
            cfg[param_name] = param_values[param_name]
        else:
            # complete with value from parameter space
            value = param_space.get_param(param_name)

            if isinstance(value, (tuple, list)) and len(value) > 1:
                raise ValueError(
                    "don't know how to complete a configuration that might have multiple values")
            else:
                if isinstance(value, (tuple, list)):
                    value = value[0]
                cfg[param_name] = value

    return cfg