-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
preload val_map from orders #2105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
235cdce
412a7f3
92c13a5
398f794
249440b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,3 +182,53 @@ def test_px_templates(): | |
assert fig.layout.xaxis3.showgrid is None | ||
assert fig.layout.yaxis2.showgrid | ||
assert fig.layout.yaxis3.showgrid | ||
|
||
|
||
def test_orthogonal_orderings(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great test! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth testing that adding in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I tried but it's a harder test to write and much slower :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I think I have a way to spot-check a few options |
||
from itertools import permutations | ||
|
||
df = px.data.tips() | ||
|
||
symbol_sequence = ["circle", "diamond", "square", "cross"] | ||
color_sequence = ["red", "blue"] | ||
|
||
def assert_orderings(days_order, days_check, times_order, times_check): | ||
fig = px.scatter( | ||
df, | ||
x="total_bill", | ||
y="tip", | ||
facet_row="time", | ||
facet_col="day", | ||
color="time", | ||
symbol="day", | ||
symbol_sequence=symbol_sequence, | ||
color_discrete_sequence=color_sequence, | ||
category_orders=dict(day=days_order, time=times_order), | ||
) | ||
|
||
for col in range(len(days_check)): | ||
for trace in fig.select_traces(col=col + 1): | ||
assert days_check[col] in trace.hovertemplate | ||
|
||
for row in range(len(times_check)): | ||
for trace in fig.select_traces(row=2 - row): | ||
assert times_check[row] in trace.hovertemplate | ||
|
||
for trace in fig.data: | ||
for i, day in enumerate(days_check): | ||
if day in trace.name: | ||
assert trace.marker.symbol == symbol_sequence[i] | ||
for i, time in enumerate(times_check): | ||
if time in trace.name: | ||
assert trace.marker.color == color_sequence[i] | ||
|
||
assert_orderings( | ||
["x", "Sun", "Sat", "y", "Fri", "z"], # add extra noise, missing Thur | ||
["Sun", "Sat", "Fri", "Thur"], # Thur is at the back | ||
["a", "Lunch", "b"], # add extra noise, missing Dinner | ||
["Lunch", "Dinner"], # Dinner is at the back | ||
) | ||
|
||
for days in permutations(df["day"].unique()): | ||
for times in permutations(df["time"].unique()): | ||
assert_orderings(days, days, times, times) |
Uh oh!
There was an error while loading. Please reload this page.