def is_valid_aesthetic(value, ae):
    """
    Return True if `value` looks valid.

    Parameters
    ----------
    value : object
        Value to check
    ae : str
        Aesthetic name

    Returns
    -------
    out : bool
        Whether the value is of a valid looking form.

    Notes
    -----
    There are no guarantees that he value is spot on
    valid.
    """

    if ae == 'linetype':
        named = {'solid', 'dashed', 'dashdot', 'dotted',
                 '_', '--', '-.', ':', 'None', ' ', ''}
        if value in named:
            return True

        # tuple of the form (offset, (on, off, on, off, ...))
        # e.g (0, (1, 2))
        conditions = [isinstance(value, tuple),
                      isinstance(value[0], int),
                      isinstance(value[1], tuple),
                      len(value[1]) % 2 == 0,
                      all(isinstance(x, int) for x in value[1])]
        if all(conditions):
            return True
        return False

    elif ae == 'shape':
        if isinstance(value, str):
            return True

        # tuple of the form (numsides, style, angle)
        # where style is in the range [0, 3]
        # e.g (4, 1, 45)
        conditions = [isinstance(value, tuple),
                      all(isinstance(x, int) for x in value),
                      0 <= value[1] < 3]
        if all(conditions):
            return True
        return False

    elif ae in {'color', 'fill'}:
        if isinstance(value, str):
            return True
        with suppress(TypeError):
            if (isinstance(value, (tuple, list)) and
                    all(0 <= x <= 1 for x in value)):
                return True
        return False

    # For any other aesthetics we return False to allow
    # for special cases to be discovered and then coded
    # for appropriately.
    return False
def is_valid_aesthetic ( value , ae ) : if ae == 'linetype' : named = { 'solid' , 'dashed' , 'dashdot' , 'dotted' , '_' , '--' , '-.' , ':' , 'None' , ' ' , '' } if value in named : return True conditions = [ isinstance ( value , tuple ) , isinstance ( value [ 0 ] , int ) , isinstance ( value [ 1 ] , tuple ) , len ( value [ 1 ] ) % 2 == 0 , all ( isinstance ( x , int ) for x in value [ 1 ] ) ] if all ( conditions ) : return True return False elif ae == 'shape' : if isinstance ( value , str ) : return True conditions = [ isinstance ( value , tuple ) , all ( isinstance ( x , int ) for x in value ) , 0 <= value [ 1 ] < 3 ] if all ( conditions ) : return True return False elif ae in { 'color' , 'fill' } : if isinstance ( value , str ) : return True with suppress ( TypeError ) : if ( isinstance ( value , ( tuple , list ) ) and all ( 0 <= x <= 1 for x in value ) ) : return True return False return False
Return True if `value` looks valid.

    Parameters
    ----------
    value : object
        Value to check
    ae : str
        Aesthetic name

    Returns
    -------
    out : bool
        Whether the value is of a valid looking form.

    Notes
    -----
    There are no guarantees that he value is spot on
    valid.