Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9043fff

Browse files
add go.Pie comparison
1 parent 3abd6d4 commit 9043fff

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

‎packages/python/plotly/plotly/tests/test_optional/test_px/test_px_functions.py‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,35 @@ def test_pie_like_px():
5858

5959
def test_pie_custom_category_order(constructor):
6060
# https://github.com/plotly/plotly.py/issues/4999
61-
df = constructor(
62-
{
63-
"status": ["On Route", "Pending", "Waiting Result", "Delivered"],
64-
"count": [28, 10, 73, 8],
65-
}
66-
)
61+
data = {
62+
"status": ["On Route", "Pending", "Waiting Result", "Delivered"],
63+
"count": [28, 10, 73, 8],
64+
}
65+
df = constructor(data)
6766
custom_order = ["Pending", "Waiting Result", "On Route", "Delivered"]
6867
result = px.pie(
6968
data_frame=df,
7069
values="count",
7170
names="status",
7271
category_orders={"status": custom_order},
73-
).to_dict()
74-
assert list(result["data"][0]["labels"]) == [
72+
)
73+
assert list(result.to_dict()["data"][0]["labels"]) == [
7574
"Pending",
7675
"Waiting Result",
7776
"On Route",
7877
"Delivered",
7978
]
79+
values_ = np.array(
80+
[
81+
x[0]
82+
for x in sorted(
83+
zip(data["count"], data["status"]),
84+
key=lambda t: custom_order.index(t[1]),
85+
)
86+
]
87+
)
88+
trace = go.Pie(values=values_, labels=custom_order)
89+
_compare_figures(trace, result)
8090

8191

8292
def test_sunburst_treemap_colorscales():

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /