-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Optimized :meth:.Axes.coords_to_point
#3286
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
Optimized :meth:.Axes.coords_to_point
#3286
Conversation
Axes.coords_to_point.Axes.coords_to_point
behackl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor suggestion, otherwise this is a fine improvement. Please take a look & thanks for your efforts!
| # Or is coords in the format (x, y, z) or ([x1 x2 ...], [y1 y2 ...], [z1 z2 ...])? (False) | ||
| # | ||
| # The latter is preferred. | ||
| are_components_xyz = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be made even more explicit: are_components_xyz is not particularly self-explanatory. Why not are_coordinates_transposed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like that one better. The original transposed variable was not really clear IMO, but in hindsight are_components_xyz is not much better.
Gonna change that!
|
Done! I changed the variable name to I also added some more commentaries and added an extra condition |
behackl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you very much!
Overview: What does this pull request change?
As the title says, I optimized
Axes.coords_to_point. Best results if combined with PR #3285: Optimized :meth:NumberLine.number_to_point.Motivation and Explanation: Why and how do your changes improve the library?
np.sumand the list comprehension, and replaced them with a good ol' for loop, which is much more efficient in this case because there are only 2 or 3 coords to add.VMobject.__iter__onself.axesby iterating directly over itssubmobjectsattribute.originby assigning first the result ofself.x_axis.number_to_point(coords[0])by separate (which should not be a problem sincex_axisis already being used explicitly to calculateorigin.The changes I propose:
The results before and after the changes (using the same test scene I used for #3285). As you can see, I managed to cutoff around 0.70 seconds from
Axes.coords_to_point. If the changes in the previous PR get accepted as well, there's even more speedup:Links to added or changed documentation pages
Further Information and Comments
Reviewer Checklist