GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Cleanup 1D case in transform_affine() by iccir · Pull Request #32547 · matplotlib/matplotlib Conversation
Contributor
PR summaryThis PR cleans up the 1D case of
I used the following benchmark to measure performance: affinebench.pyimport random import time import timeit import numpy as np from matplotlib.transforms import Affine2D transform = Affine2D().scale(2.0).translate(10.0, 20.0) rng = np.random.default_rng(42) points = [(random.uniform(-1, 1), random.uniform(-1, 1)) for _ in range(100_000)] total_time = timeit.timeit( lambda: [transform.transform_affine(point) for point in points], number=1, ) print(f"Total time: {total_time * 1000:.3f} ms") On my machine, total time goes from ~310ms to ~82ms. AI Disclosure
PR quality check
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
scottshambaugh
approved these changes
Contributor
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. This looks perfectly readable to me! I'd take the performance over your alternative
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
timhoffm
reviewed
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Co-authored-by: Tim Hoffmann <[email protected]>
timhoffm
approved these changes
Member
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. Can't check easily on the phone: Is the new scalar branch covered in the tests?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
timhoffm
reviewed
Member
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. I’m not clear this is actually an improvement. It creates more indirection and makes the test harder to follow.
Suggested change
Read: “r90 transforms [1, 1] approximately to [-1, 1]” If you want to abstract from here, it should be something like
Suggested change
I also would not create separate check functions for multiple points. Either explicitly spell this out as
Suggested change
or absorb the logic into For multiple points, stating the inputs is a bit longer and may need wrapping, but I think that’s still preferable to a magic distant input.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
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. I'm not a fan of I like Are you ok with the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
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. I’m fundamentally ok with
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
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. The existing use of For example,
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
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. It would probably be better to change that specific test case to use That works on my machine (arm64), but it may not be portable to other architectures, compilers, and/or versions of Python/numpy.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
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. Sounds good to me!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
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. I think the rotations around 90 degrees can't be The
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
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. @timhoffm - Since I touched a lot of the tests in this PR, would it be better to back those changes out and do a follow-up PR that only touches the tests?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
If @timhoffm is ok with it, I think I'd rather have a follow-up PR that only touches the tests and merge this as-is. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.