-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathtest_data.py
88 lines (77 loc) · 2.57 KB
/
test_data.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import pytest
from plotly import optional_imports
from ...test_optional.optional_utils import run_fig
from ...test_optional.test_matplotlylib.data.data import *
matplotlylib = optional_imports.get_module("plotly.matplotlylib")
if matplotlylib:
import matplotlib.pyplot as plt
@pytest.mark.skip
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"])
)
@pytest.mark.skip
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"])
)
@pytest.mark.skip
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"])
)
@pytest.mark.skip
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"])
)