示例#1
0
def test_convert_y_success_temporal(column):
    chart = ChartMetadata(alt.Chart(df).mark_point().encode(alt.Y(column)))
    mapping = _convert(chart)
    assert list(mapping['y']) == list(mdates.date2num(df[column].values))
示例#2
0
def test_convert_x_success(channel):
    chart_spec = alt.Chart(df).encode(x=channel).mark_point()
    chart = ChartMetadata(chart_spec)
    mapping = _convert(chart)
    assert list(mapping['x']) == list(df[channel].values)
示例#3
0
def test_convert_y_success(channel):
    chart_spec = ChartMetadata(alt.Chart(df).encode(y=channel).mark_point())
    mapping = _convert(chart_spec)
    assert list(mapping['y']) == list(df[channel].values)
示例#4
0
def test_convert_stroke_fail_temporal(column):
    chart = ChartMetadata(
        alt.Chart(df).mark_point().encode(alt.Stroke(column)))
    _convert(chart)
示例#5
0
def test_invalid_encodings():
    chart_spec = alt.Chart(df).encode(x2='quant').mark_point()
    chart = ChartMetadata(chart_spec)
    with pytest.raises(ValueError):
        _convert(chart)
示例#6
0
def test_convert_size_success_nominal():
    with pytest.raises(NotImplementedError):
        chart_spec = ChartMetadata(
            alt.Chart(df).encode(size='nom').mark_point())
        _convert(chart_spec)
示例#7
0
def test_quantitative_stroke():
    chart = ChartMetadata(
        alt.Chart(df_quant).mark_point().encode(alt.Stroke('fill')))
    _convert(chart)
示例#8
0
def test_convert_opacity_fail_temporal(column):
    chart = ChartMetadata(
        alt.Chart(df).mark_point().encode(alt.Opacity(column)))
    _convert(chart)
示例#9
0
def test_convert_size_success(channel, type):
    chart_spec = ChartMetadata(
        alt.Chart(df).encode(size='{}:{}'.format(channel, type)).mark_point())
    mapping = _convert(chart_spec)
    assert list(mapping['s']) == list(df[channel].values)
示例#10
0
def test_quantitative_opacity_array():
    chart = ChartMetadata(
        alt.Chart(df_quant).mark_point().encode(alt.Opacity('alpha')))
    _convert(chart)
示例#11
0
def test_quantitative_shape():
    chart = ChartMetadata(
        alt.Chart(df_quant).mark_point().encode(alt.Shape('shape')))
    mapping = _convert(chart)
示例#12
0
def test_convert_color_success(channel, dtype):
    chart_spec = ChartMetadata(
        alt.Chart(df).encode(
            color=alt.Color(field=channel, type=dtype)).mark_point())
    mapping = _convert(chart_spec)
    assert list(mapping['c']) == list(df[channel].values)
示例#13
0
def test_convert_x2_y2_fail_temporal(column):
    chart = ChartMetadata(
        alt.Chart(df).mark_point().encode(alt.X2(column), alt.Y2(column)))
    _convert(chart)
示例#14
0
def test_quantitative_x2_y2():
    chart = ChartMetadata(
        alt.Chart(df_quant).mark_point().encode(alt.X('a'), alt.Y('b'),
                                                alt.X2('c'), alt.Y2('alpha')))
    _convert(chart)