(values)
return (not (unique_float - {0, 1}) or
            not (unique_float - {1, 2})) and unique
Return set of uniques if `values` is an iterable of discrete values
    else False if non-discrete, or None if indeterminate.

    Note
    ----
    Assumes consistent type of items of `values`.
Return set of uniques if `values` is an iterable of discrete values
    else False if non-discrete, or None if indeterminate.
Return set of uniques if values is an iterable of discrete values else False if non - discrete or None if indeterminate .
def is_discrete_values(values):
    """
    Return set of uniques if `values` is an iterable of discrete values
    else False if non-discrete, or None if indeterminate.

    Note
    ----
    Assumes consistent type of items of `values`.
    """
    if len(values) == 0:
        return None
    # If the first few values are, or can be converted to, floats,
    # the type is numeric
    try:
        isinstance(next(iter(values)), Number) or \
        [v not in MISSING_VALUES and float(v)
         for _, v in zip(range(min(3, len(values))), values)]
    except ValueError:
        is_numeric = False
        max_values = int(round(len(values)**.7))
    else:
        is_numeric = True
        max_values = DISCRETE_MAX_VALUES

    # If more than max values => not discrete
    unique = set()
    for i in values:
        unique.add(i)
        if (len(unique) > max_values or
                len(unique) > DISCRETE_MAX_ALLOWED_VALUES):
            return False

    # Strip NaN from unique
    unique = {i for i in unique
              if (not i in MISSING_VALUES and
                  not (isinstance(i, Number) and np.isnan(i)))}

    # All NaNs => indeterminate
    if not unique:
        return None

    # Strings with |values| < max_unique
    if not is_numeric:
        return unique

    # Handle numbers
    try:
        unique_float = set(map(float, unique))
    except ValueError:
        # Converting all the values to floats resulted in an error.
        # Since the values have enough unique values, they are probably
        # string values and discrete.
        return unique

    # If only values are {0, 1} or {1, 2} (or a subset of those sets) => discrete
    return (not (unique_float - {0, 1}) or
            not (unique_float - {1, 2})) and unique
def is_discrete_values ( values ) : if len ( values ) == 0 : return None # If the first few values are, or can be converted to, floats, # the type is numeric try : isinstance ( next ( iter ( values ) ) , Number ) or [ v not in MISSING_VALUES and float ( v ) for _ , v in zip ( range ( min ( 3 , len ( values ) ) ) , values ) ] except ValueError : is_numeric = False max_values = int ( round ( len ( values ) ** .7 ) ) else : is_numeric = True max_values = DISCRETE_MAX_VALUES # If more than max values => not discrete unique = set ( ) for i in values : unique . add ( i ) if ( len ( unique ) > max_values or len ( unique ) > DISCRETE_MAX_ALLOWED_VALUES ) : return False # Strip NaN from unique unique = { i for i in unique if ( not i in MISSING_VALUES and not ( isinstance ( i , Number ) and np . isnan ( i ) ) ) } # All NaNs => indeterminate if not unique : return None # Strings with |values| < max_unique if not is_numeric : return unique # Handle numbers try : unique_float = set ( map ( float , unique ) ) except ValueError : # Converting all the values to floats resulted in an error. # Since the values have enough unique values, they are probably # string values and discrete. return unique # If only values are {0, 1} or {1, 2} (or a subset of those sets) => discrete return ( not ( unique_float - { 0 , 1 } ) or not ( unique_float - { 1 , 2 } ) ) and unique