示例#1
0
def test_hermite_kochanek_bartels(Chart, datas):
    """Test hermite kochanek bartels interpolation"""
    chart = Chart(interpolate='hermite',
                  interpolation_parameters={
                      'type': 'kochanek_bartels',
                      'b': -1,
                      'c': 1,
                      't': 1
                  })
    chart = make_data(chart, datas)
    assert chart.render()

    chart = Chart(interpolate='hermite',
                  interpolation_parameters={
                      'type': 'kochanek_bartels',
                      'b': -1,
                      'c': -8,
                      't': 0
                  })
    chart = make_data(chart, datas)
    assert chart.render()

    chart = Chart(interpolate='hermite',
                  interpolation_parameters={
                      'type': 'kochanek_bartels',
                      'b': 0,
                      'c': 10,
                      't': -1
                  })
    chart = make_data(chart, datas)
    assert chart.render()
示例#2
0
def test_cubic_prec(Chart, datas):
    chart = Chart(interpolate='cubic', interpolation_precision=200)
    chart = make_data(chart, datas)

    chart_low = Chart(interpolate='cubic', interpolation_precision=5)
    chart_low = make_data(chart, datas)

    assert len(chart.render()) >= len(chart_low.render())
示例#3
0
def test_cubic_prec(Chart, datas):
    chart = Chart(interpolate='cubic', interpolation_precision=200)
    chart = make_data(chart, datas)

    chart_low = Chart(interpolate='cubic', interpolation_precision=5)
    chart_low = make_data(chart, datas)

    assert len(chart.render()) >= len(chart_low.render())
示例#4
0
def test_cubic_prec(Chart, datas):
    """Test cubic interpolation precision"""
    chart = Chart(interpolate="cubic", interpolation_precision=200)
    chart = make_data(chart, datas)

    chart_low = Chart(interpolate="cubic", interpolation_precision=5)
    chart_low = make_data(chart, datas)

    assert len(chart.render()) >= len(chart_low.render())
示例#5
0
def test_multi_render(Chart, datas):
    """Check that a chart always render the same"""
    chart = Chart()
    chart = make_data(chart, datas)
    svg = chart.render()
    for i in range(2):
        assert svg == chart.render()
示例#6
0
def test_hermite_kochanek_bartels(Chart, datas):
    chart = Chart(interpolate="hermite", interpolation_parameters={"type": "kochanek_bartels", "b": -1, "c": 1, "t": 1})
    chart = make_data(chart, datas)
    assert chart.render()

    chart = Chart(
        interpolate="hermite", interpolation_parameters={"type": "kochanek_bartels", "b": -1, "c": -8, "t": 0}
    )
    chart = make_data(chart, datas)
    assert chart.render()

    chart = Chart(
        interpolate="hermite", interpolation_parameters={"type": "kochanek_bartels", "b": 0, "c": 10, "t": -1}
    )
    chart = make_data(chart, datas)
    assert chart.render()
示例#7
0
def test_hermite_cardinal(Chart, datas):
    chart = Chart(interpolate='hermite',
                  interpolation_parameters={
                      'type': 'cardinal',
                      'c': .75
                  })
    chart = make_data(chart, datas)
    assert chart.render()
示例#8
0
def test_multi_render(Chart, datas):
    chart = Chart()
    chart = make_data(chart, datas)
    chart.x_labels = (str(a) for a in 'labels')
    chart.y_labels = (str(a) for a in range(6))
    svg = chart.render()
    for i in range(2):
        assert svg == chart.render()
示例#9
0
def test_hermite_catmull_rom(Chart, datas):
    """Test hermite catmull rom interpolation"""
    chart = Chart(
        interpolate='hermite',
        interpolation_parameters={'type': 'catmull_rom'}
    )
    chart = make_data(chart, datas)
    assert chart.render()
示例#10
0
def test_hermite_finite(Chart, datas):
    """Test hermite finite difference interpolation"""
    chart = Chart(
        interpolate='hermite',
        interpolation_parameters={'type': 'finite_difference'}
    )
    chart = make_data(chart, datas)
    assert chart.render()
示例#11
0
def test_hermite_kochanek_bartels(Chart, datas):
    chart = Chart(interpolate='hermite',
                  interpolation_parameters={
                      'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': 1})
    chart = make_data(chart, datas)
    assert chart.render()

    chart = Chart(interpolate='hermite',
                  interpolation_parameters={
                      'type': 'kochanek_bartels', 'b': -1, 'c': -8, 't': 0})
    chart = make_data(chart, datas)
    assert chart.render()

    chart = Chart(interpolate='hermite',
                  interpolation_parameters={
                      'type': 'kochanek_bartels', 'b': 0, 'c': 10, 't': -1})
    chart = make_data(chart, datas)
    assert chart.render()
示例#12
0
def test_long_title(Chart, datas):
    chart = Chart(
        title="A chart is a graphical representation of data, in which "
        "'the data is represented by symbols, such as bars in a bar chart, "
        "lines in a line chart, or slices in a pie chart'. A chart can "
        "represent tabular numeric data, functions or some kinds of "
        "qualitative structure and provides different info.")
    chart = make_data(chart, datas)
    q = chart.render_pyquery()
    assert len(q('.titles text')) == 5
示例#13
0
def test_render_to_file(Chart, datas):
    file_name = '/tmp/test_graph-%s.svg' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)

    chart = Chart()
    chart = make_data(chart, datas)
    chart.render_to_file(file_name)
    with open(file_name) as f:
        assert 'pygal' in f.read()
    os.remove(file_name)
示例#14
0
def test_render_to_file(Chart, datas):
    file_name = '/tmp/test_graph-%s.svg' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)

    chart = Chart()
    chart = make_data(chart, datas)
    chart.render_to_file(file_name)
    with open(file_name) as f:
        assert 'pygal' in f.read()
    os.remove(file_name)
示例#15
0
def test_hermite_cardinal(Chart, datas):
    """Test hermite cardinal interpolation"""
    chart = Chart(
        interpolate='hermite',
        interpolation_parameters={
            'type': 'cardinal',
            'c': .75
        }
    )
    chart = make_data(chart, datas)
    assert chart.render()
示例#16
0
def test_render_to_file(Chart, datas):
    """Test in file rendering"""
    file_name = '/tmp/test_graph-%s.svg' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)

    chart = Chart()
    chart = make_data(chart, datas)
    chart.render_to_file(file_name)
    with io.open(file_name, encoding="utf-8") as f:
        assert 'pygal' in f.read()
    os.remove(file_name)
示例#17
0
def test_render_to_png(Chart, datas):
    file_name = '/tmp/test_graph-%s.png' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)

    chart = Chart()
    chart = make_data(chart, datas)
    chart.render_to_png(file_name)
    png = chart._repr_png_()

    with open(file_name, 'rb') as f:
        assert png == f.read()
    os.remove(file_name)
示例#18
0
def test_render_to_png(Chart, datas):
    try:
        import cairosvg
    except ImportError:
        return

    file_name = '/tmp/test_graph-%s.png' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)

    chart = Chart()
    chart = make_data(chart, datas)
    chart.render_to_png(file_name)
    with open(file_name, 'rb') as f:
        assert f.read()
    os.remove(file_name)
示例#19
0
def test_render_to_png(Chart, datas):
    try:
        import cairosvg
    except ImportError:
        return

    file_name = '/tmp/test_graph-%s.png' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)

    chart = Chart()
    chart = make_data(chart, datas)
    chart.render_to_png(file_name)
    with open(file_name, 'rb') as f:
        assert f.read()
    os.remove(file_name)
示例#20
0
def test_hermite(Chart, datas):
    chart = Chart(interpolate='hermite')
    chart = make_data(chart, datas)
    assert chart.render()
示例#21
0
def test_quadratic(Chart, datas):
    """Test quadratic interpolation"""
    chart = Chart(interpolate="quadratic")
    chart = make_data(chart, datas)
    assert chart.render()
示例#22
0
def test_hermite_cardinal(Chart, datas):
    """Test hermite cardinal interpolation"""
    chart = Chart(interpolate="hermite", interpolation_parameters={"type": "cardinal", "c": 0.75})
    chart = make_data(chart, datas)
    assert chart.render()
示例#23
0
def test_ipython_notebook(Chart, datas):
    """Test ipython notebook"""
    chart = Chart()
    chart = make_data(chart, datas)
    assert chart._repr_svg_()
示例#24
0
def test_sparkline(Chart, datas):
    """Test sparkline"""
    chart = Chart()
    chart = make_data(chart, datas)
    assert chart.render_sparkline()
示例#25
0
def test_quadratic(Chart, datas):
    chart = Chart(interpolate='quadratic')
    chart = make_data(chart, datas)
    assert chart.render()
示例#26
0
def test_quadratic(Chart, datas):
    """Test quadratic interpolation"""
    chart = Chart(interpolate='quadratic')
    chart = make_data(chart, datas)
    assert chart.render()
示例#27
0
def test_lagrange(Chart, datas):
    """Test lagrange interpolation"""
    chart = Chart(interpolate="lagrange")
    chart = make_data(chart, datas)
    assert chart.render()
示例#28
0
def test_trigonometric(Chart, datas):
    """Test trigonometric interpolation"""
    chart = Chart(interpolate="trigonometric")
    chart = make_data(chart, datas)
    assert chart.render()
示例#29
0
def test_hermite(Chart, datas):
    """Test hermite interpolation"""
    chart = Chart(interpolate="hermite")
    chart = make_data(chart, datas)
    assert chart.render()
示例#30
0
def test_multi_render(Chart, datas):
    chart = Chart()
    chart = make_data(chart, datas)
    svg = chart.render()
    for i in range(2):
        assert svg == chart.render()
示例#31
0
def test_hermite_catmull_rom(Chart, datas):
    """Test hermite catmull rom interpolation"""
    chart = Chart(interpolate="hermite", interpolation_parameters={"type": "catmull_rom"})
    chart = make_data(chart, datas)
    assert chart.render()
示例#32
0
def test_trigonometric(Chart, datas):
    chart = Chart(interpolate='trigonometric')
    chart = make_data(chart, datas)
    assert chart.render()
示例#33
0
def test_lagrange(Chart, datas):
    chart = Chart(interpolate='lagrange')
    chart = make_data(chart, datas)
    assert chart.render()
示例#34
0
def test_lagrange(Chart, datas):
    """Test lagrange interpolation"""
    chart = Chart(interpolate='lagrange')
    chart = make_data(chart, datas)
    assert chart.render()
示例#35
0
def test_multi_render(Chart, datas):
    chart = Chart()
    chart = make_data(chart, datas)
    svg = chart.render()
    for i in range(2):
        assert svg == chart.render()
示例#36
0
def test_trigonometric(Chart, datas):
    """Test trigonometric interpolation"""
    chart = Chart(interpolate='trigonometric')
    chart = make_data(chart, datas)
    assert chart.render()
示例#37
0
def test_hermite(Chart, datas):
    """Test hermite interpolation"""
    chart = Chart(interpolate='hermite')
    chart = make_data(chart, datas)
    assert chart.render()
示例#38
0
def test_hermite_finite(Chart, datas):
    """Test hermite finite difference interpolation"""
    chart = Chart(interpolate='hermite',
                  interpolation_parameters={'type': 'finite_difference'})
    chart = make_data(chart, datas)
    assert chart.render()
示例#39
0
def test_cubic(Chart, datas):
    chart = Chart(interpolate='cubic')
    chart = make_data(chart, datas)
    assert chart.render()
示例#40
0
def test_hermite_catmull_rom(Chart, datas):
    """Test hermite catmull rom interpolation"""
    chart = Chart(interpolate='hermite',
                  interpolation_parameters={'type': 'catmull_rom'})
    chart = make_data(chart, datas)
    assert chart.render()
示例#41
0
def test_cubic(Chart, datas):
    chart = Chart(interpolate='cubic')
    chart = make_data(chart, datas)
    assert chart.render()
示例#42
0
def test_hermite_finite(Chart, datas):
    """Test hermite finite difference interpolation"""
    chart = Chart(interpolate="hermite", interpolation_parameters={"type": "finite_difference"})
    chart = make_data(chart, datas)
    assert chart.render()