-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathtest_bars.py
84 lines (67 loc) · 2.24 KB
/
test_bars.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
import pytest
from plotly import optional_imports
from ...utils import compare_dict, strip_dict_params
from ...test_optional.optional_utils import run_fig
from ...test_optional.test_matplotlylib.data.bars import *
matplotlylib = optional_imports.get_module("plotly.matplotlylib")
if matplotlylib:
import matplotlib.pyplot as plt
@pytest.mark.skip
def test_vertical_bar():
fig, ax = plt.subplots()
ax.bar(left=D["left"], height=D["height"])
renderer = run_fig(fig)
for data_no, data_dict in enumerate(renderer.plotly_fig["data"]):
d1, d2 = strip_dict_params(
data_dict, VERTICAL_BAR["data"][data_no], ignore=["uid"]
)
equivalent, msg = compare_dict(d1, d2)
assert equivalent, msg
equivalent, msg = compare_dict(
renderer.plotly_fig["layout"], VERTICAL_BAR["layout"]
)
assert equivalent, msg
@pytest.mark.skip
def test_horizontal_bar():
fig, ax = plt.subplots()
ax.barh(bottom=D["bottom"], width=D["width"])
renderer = run_fig(fig)
for data_no, data_dict in enumerate(renderer.plotly_fig["data"]):
d1, d2 = strip_dict_params(
data_dict, HORIZONTAL_BAR["data"][data_no], ignore=["uid"]
)
equivalent, msg = compare_dict(d1, d2)
assert equivalent, msg
equivalent, msg = compare_dict(
renderer.plotly_fig["layout"], HORIZONTAL_BAR["layout"]
)
assert equivalent, msg
@pytest.mark.skip
def test_h_and_v_bars():
fig, ax = plt.subplots()
ax.bar(
left=D["multi_left"],
height=D["multi_height"],
width=10,
color="green",
alpha=0.5,
)
# changing height 10 -> 14 because ValueError if bargap not in [0, 1]
ax.barh(
bottom=D["multi_bottom"],
width=D["multi_width"],
height=14,
color="red",
alpha=0.5,
)
renderer = run_fig(fig)
for data_no, data_dict in enumerate(renderer.plotly_fig["data"]):
d1, d2 = strip_dict_params(
data_dict, H_AND_V_BARS["data"][data_no], ignore=["uid"]
)
equivalent, msg = compare_dict(d1, d2)
assert equivalent, msg
equivalent, msg = compare_dict(
renderer.plotly_fig["layout"], H_AND_V_BARS["layout"]
)
assert equivalent, msg