forked from plotly/plotly.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_data.py
More file actions
57 lines (48 loc) · 2.19 KB
/
test_data.py
File metadata and controls
57 lines (48 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import matplotlib.pyplot as plt
from .nose_tools import run_fig
from .data.data import *
def test_line_data():
fig, ax = plt.subplots()
ax.plot(D['x1'], D['y1'])
renderer = run_fig(fig)
for xi, xf, yi, yf in zip(renderer.plotly_fig['data'][0]['x'], D['x1'],
renderer.plotly_fig['data'][0]['y'], D['y1']):
assert xi == xf, str(
renderer.plotly_fig['data'][0]['x']) + ' is not ' + str(D['x1'])
assert yi == yf, str(
renderer.plotly_fig['data'][0]['y']) + ' is not ' + str(D['y1'])
def test_lines_data():
fig, ax = plt.subplots()
ax.plot(D['x1'], D['y1'])
ax.plot(D['x2'], D['y2'])
renderer = run_fig(fig)
for xi, xf, yi, yf in zip(renderer.plotly_fig['data'][0]['x'], D['x1'],
renderer.plotly_fig['data'][0]['y'], D['y1']):
assert xi == xf, str(
renderer.plotly_fig['data'][0]['x']) + ' is not ' + str(D['x1'])
assert yi == yf, str(
renderer.plotly_fig['data'][0]['y']) + ' is not ' + str(D['y1'])
for xi, xf, yi, yf in zip(renderer.plotly_fig['data'][1]['x'], D['x2'],
renderer.plotly_fig['data'][1]['y'], D['y2']):
assert xi == xf, str(
renderer.plotly_fig['data'][1]['x']) + ' is not ' + str(D['x2'])
assert yi == yf, str(
renderer.plotly_fig['data'][0]['y']) + ' is not ' + str(D['y2'])
def test_bar_data():
fig, ax = plt.subplots()
ax.bar(D['x1'], D['y1'])
renderer = run_fig(fig)
for yi, yf in zip(renderer.plotly_fig['data'][0]['y'], D['y1']):
assert yi == yf, str(
renderer.plotly_fig['data'][0]['y']) + ' is not ' + str(D['y1'])
def test_bars_data():
fig, ax = plt.subplots()
ax.bar(D['x1'], D['y1'], color='r')
ax.barh(D['x2'], D['y2'], color='b')
renderer = run_fig(fig)
for yi, yf in zip(renderer.plotly_fig['data'][0]['y'], D['y1']):
assert yi == yf, str(
renderer.plotly_fig['data'][0]['y']) + ' is not ' + str(D['y1'])
for xi, yf in zip(renderer.plotly_fig['data'][1]['x'], D['y2']):
assert xi == yf, str(
renderer.plotly_fig['data'][1]['x']) + ' is not ' + str(D['y2'])