def test_select_y():
    def _check(data, expected, aggregator=None):
        v = api.Viz(data)
        v.encode()
        v.encoding.x = 'col1'
        if aggregator != None:
            v.select_y()
            assert v.encoding.y.name == expected
        else:
            v.select_y(None, aggregator)
            assert v.encoding.y.name == expected
            assert v.encoding.y.aggregate == aggregator

    data = dict(col1=[1.0, 2.0, 3.0],  # Chosen X
                col2=['A', 'B', 'C'],  # N
                col3=pd.date_range('2012', periods=3, freq='A'),  # T
                col4=pd.date_range('2012', periods=3, freq='A'),  # T
                col5=[1.0, 2.0, 3.0],  # Q
                col6=[1.0, 2.0, 3.0])  # Q
    _check(data, 'col5')
    _check(data, 'col5', 'avg')

    data = dict(col1=[1.0, 2.0, 3.0],  # Chosen X
                col2=['A', 'B', 'C'],  # N
                col3=pd.date_range('2012', periods=3, freq='A'),  # T
                col4=['A', 'B', 'C'])  # N
    _check(data, 'col2')
    _check(data, 'col2', 'sum')

    data = dict(col1=[1.0, 2.0, 3.0],  # Chosen X
                col2=pd.date_range('2012', periods=3, freq='A'),  # T
                col3=pd.date_range('2012', periods=3, freq='A'))  # T
    _check(data, 'col2')
    _check(data, 'col2', 'sum')

    # No data
    with pytest.raises(AssertionError):
        v = api.Viz(None)
        v.select_y()

    # Just one column
    with pytest.raises(AssertionError):
        v = api.Viz(dict(col1=[1.0,2.0]))
        v.select_y()

    # No encoding
    with pytest.raises(AssertionError):
        v = api.Viz(dict(col1=[1.0,2.0], col2=[1.0,2.0]))
        v.select_y()

    # No X
    with pytest.raises(AssertionError):
        v = api.Viz(dict(col1=[1.0,2.0], col2=[1.0,2.0]))
        v.encode()
        v.select_y()

    # Custom order
    data = dict(col1=[1.0, 2.0, 3.0],  # Chosen X
                col2=['A', 'B', 'C'],  # N
                col3=pd.date_range('2012', periods=3, freq='A'),  # T
                col4=pd.date_range('2012', periods=3, freq='A'),  # T
                col5=[1.0, 2.0, 3.0],  # Q
                col6=[1.0, 2.0, 3.0])  # Q
    v = api.Viz(data)
    v.encode()
    v.encoding.x = 'col1'
    v.select_y(['N', 'T', 'Q', 'O'])
    assert v.encoding.y.name == 'col2'
dataset/ETHPy150Open ellisonbg/altair/altair/tests/test_api.py/test_select_y/operator `is` -> `!=`