Пример #1
0
def _is_function(val):
    if not isinstance(val, six.string_types):
        return False
    try:
        op_util.parse_function(val)
    except ValueError:
        return False
    else:
        return True
Пример #2
0
def _try_function_dim(val, flag_name):
    assert isinstance(val, six.string_types), val
    try:
        func_name, func_args = op_util.parse_function(val)
    except ValueError:
        raise ValueError(val, flag_name)
    else:
        return _function_dim(func_name, func_args, flag_name)
Пример #3
0
def _flag_dim(val, flag_name):
    if isinstance(val, list):
        return val
    try:
        dist_name, min_max = op_util.parse_function(val)
    except ValueError:
        return [val]
    else:
        _validate_min_max(min_max, dist_name, flag_name)
        return min_max
Пример #4
0
def _flag_dim(val, flag_name):
    _patch_numpy_deprecation_warnings()
    from skopt.space import space
    if isinstance(val, list):
        return space.Categorical(val), None
    try:
        func_name, func_args = op_util.parse_function(val)
    except ValueError:
        return space.Categorical([val]), val
    else:
        return _function_dim(func_name, func_args, flag_name)