(descriptor, env, data, use_values)
return descriptor, func
(descriptor, env) ->
        (descriptor, (instance -> value) | (table -> value list))
(descriptor, env) ->
        (descriptor, (instance -> value) | (table -> value list))
( descriptor env ) - > ( descriptor ( instance - > value ) | ( table - > value list ))
def bind_variable(descriptor, env, data, use_values):
    """
    (descriptor, env) ->
        (descriptor, (instance -> value) | (table -> value list))
    """
    if not descriptor.expression.strip():
        return descriptor, FeatureFunc("nan", [], {"nan": float("nan")})

    exp_ast = ast.parse(descriptor.expression, mode="eval")
    freev = unique(freevars(exp_ast, []))
    variables = {unicodedata.normalize("NFKC", sanitized_name(v.name)): v
                 for v in env}
    source_vars = [(name, variables[name]) for name in freev
                   if name in variables]

    values = {}
    cast = None
    nan = float("nan")

    if isinstance(descriptor, DiscreteDescriptor):
        if not descriptor.values:
            str_func = FeatureFunc(descriptor.expression, source_vars,
                                   use_values=use_values)
            values = sorted({str(x) for x in str_func(data)})
            values = {name: i for i, name in enumerate(values)}
            descriptor = descriptor._replace(values=values)

            def cast(x):  # pylint: disable=function-redefined
                return values.get(x, nan)

        else:
            values = [sanitized_name(v) for v in descriptor.values]
            values = {name: i for i, name in enumerate(values)}

    if isinstance(descriptor, DateTimeDescriptor):
        parse = Orange.data.TimeVariable("_").parse

        def cast(e):  # pylint: disable=function-redefined
            if isinstance(e, (int, float)):
                return e
            if e == "" or e is None:
                return np.nan
            return parse(e)

    func = FeatureFunc(descriptor.expression, source_vars, values, cast,
                       use_values=use_values)
    return descriptor, func
def bind_variable ( descriptor , env , data , use_values ) : if not descriptor . expression . strip ( ) : return descriptor , FeatureFunc ( "nan" , [ ] , { "nan" : float ( "nan" ) } ) exp_ast = ast . parse ( descriptor . expression , mode = "eval" ) freev = unique ( freevars ( exp_ast , [ ] ) ) variables = { unicodedata . normalize ( "NFKC" , sanitized_name ( v . name ) ) : v for v in env } source_vars = [ ( name , variables [ name ] ) for name in freev if name in variables ] values = { } cast = None nan = float ( "nan" ) if isinstance ( descriptor , DiscreteDescriptor ) : if not descriptor . values : str_func = FeatureFunc ( descriptor . expression , source_vars , use_values = use_values ) values = sorted ( { str ( x ) for x in str_func ( data ) } ) values = { name : i for i , name in enumerate ( values ) } descriptor = descriptor . _replace ( values = values ) def cast ( x ) : # pylint: disable=function-redefined return values . get ( x , nan ) else : values = [ sanitized_name ( v ) for v in descriptor . values ] values = { name : i for i , name in enumerate ( values ) } if isinstance ( descriptor , DateTimeDescriptor ) : parse = Orange . data . TimeVariable ( "_" ) . parse def cast ( e ) : # pylint: disable=function-redefined if isinstance ( e , ( int , float ) ) : return e if e == "" or e is None : return np . nan return parse ( e ) func = FeatureFunc ( descriptor . expression , source_vars , values , cast , use_values = use_values ) return descriptor , func