Refactored reduce_across_dimension to get_extreme_coord_along_dimension#4656
Open
GoThrones wants to merge 4 commits intoManimCommunity:mainfrom
Open
Refactored reduce_across_dimension to get_extreme_coord_along_dimension#4656GoThrones wants to merge 4 commits intoManimCommunity:mainfrom
GoThrones wants to merge 4 commits intoManimCommunity:mainfrom
Conversation
for more information, see https://pre-commit.ci
…/GoThrones/ManimCE into refactor-reduce-across-dimension
Member
|
Hi! IIRC |
Contributor
Author
|
Here' the benchmarking code that i used: from manim import *
import timeit
class BenchmarkScenePR(Scene):
def construct(self):
mob = Square()
self.add(mob)
results = timeit.repeat(
lambda: mob.get_extreme_coord_along_dimension(np.max,0),
number= 100000,
repeat = 10
)
best = min(results[1:])
print(f"100k calls: {best:.4f}s ({best/100_000*1e6:.2f} µs/call)")
class BenchmarkScenemain(Scene):
def construct(self):
mob = Square()
self.add(mob)
results = timeit.repeat(
lambda: mob.reduce_across_dimension(np.max,0),
number=100000,
repeat = 10
)
best = min(results[1:])
print(f"100k calls: {best:.4f}s ({best/100_000*1e6:.2f} µs/call)")
For main: time was 4.73 µs/call and for PR branch it was 4.68 µs/call. |
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.
Overview: What does this pull request change?
This PR improves the code of the erstwhile method reduce_across_dimension, and renames it to get_extreme_coord_along_dimenstion.
Motivation and Explanation: Why and how do your changes improve the library?
The erstwhile method's name: "reduce_across_dimension" was not intuitively named. This method is only called by one other method named length_over_dim() which is also in mobject.py file, in the entire source code of manimce, and the method's name was not intuitive enough as to what it did.
Reviewer Checklist