fix: custom category order was hard-coded#5000
Merged
emilykl merged 2 commits intoplotly:masterfrom Jan 30, 2025
Merged
Conversation
cc8a1a1 to
b2b0282
Compare
b2b0282 to
3abd6d4
Compare
FBruzzesi
reviewed
Jan 30, 2025
| "On Route", | ||
| "Delivered", | ||
| ] | ||
|
|
Contributor
There was a problem hiding this comment.
I was doing a similar fix 🙈
You could also add the comparison with go.Pie:
values_ = np.array([
x[0] for x in sorted(zip(data["count"], data["status"]), key=lambda t: custom_order.index(t[1]))
])
trace = go.Pie(
values=values_,
labels=custom_order,
)
_compare_figures(trace, fig)
Contributor
Author
There was a problem hiding this comment.
yup, thanks for reviewing!
emilykl
reviewed
Jan 30, 2025
| nw.col("b") | ||
| .replace_strict(order, range(len(order)), return_dtype=nw.UInt32) | ||
| nw.col(names) | ||
| .replace_strict(order, np.arange(len(order)), return_dtype=nw.UInt32) |
Contributor
There was a problem hiding this comment.
@MarcoGorelli What's the reason for using np.arange here rather than range? Is there a performance difference?
Contributor
Author
There was a problem hiding this comment.
yes, @FBruzzesi had noted that it was generally more performant, and numpy is still required in plotly express anyway - no objections to changing this back of course!
Contributor
There was a problem hiding this comment.
Yup, makes sense to me, thanks!
emilykl
approved these changes
Jan 30, 2025
Contributor
emilykl
left a comment
There was a problem hiding this comment.
Looks good @MarcoGorelli , thanks for the fix. 🎉
Contributor
Author
|
thanks for your review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #4999