

def test_select_x():

    def _check(data, expected):
        v = api.Viz(data)
        v.select_x()
        assert (v.encoding.x.name == expected)
    data = dict(col1=[1.0, 2.0, 3.0], col2=['A', 'B', 'C'], col3=pd.date_range('2012', periods=3, freq='A'), col4=pd.date_range('2012', periods=3, freq='A'))
    _check(data, 'col3')
    data = dict(col1=[1.0, 2.0, 3.0], col2=['A', 'B', 'C'], col3=['A', 'B', 'C'])
    _check(data, 'col2')
    data = dict(col1=[1.0, 2.0, 3.0], col2=np.arange(3))
    _check(data, 'col1')
    with pytest.raises(AssertionError):
        v = api.Viz(None)
        v.select_x()
    with pytest.raises(AssertionError):
        v = api.Viz(dict())
        v.select_x()
    data = dict(col1=[1.0, 2.0, 3.0], col2=['A', 'B', 'C'], col3=pd.date_range('2012', periods=3, freq='A'), col4=pd.date_range('2012', periods=3, freq='A'))
    v = api.Viz(data)
    v.select_x(['N', 'T', 'Q', 'O'])
    assert (v.encoding.x.name == 'col2')

dataset/ETHPy150Open ellisonbg/altair/altair/tests/test_api.py test_select_x/original