Repository navigation
Don't assume transform is valid on access to matrix. - #14840
Merged
Merged
Conversation
Member
|
It looks like this breaks some of the tests. Could you give an example script that needs this fix to work? |
Contributor
Author
|
Currently this will fail, as will any other functions that internally use get_matrix. import numpy as np
from matplotlib.transforms import Affine2D
point = [1.0, 1.0]
t = Affine2D.identity()
# Transform of inverted transform returns same point, True
print(np.all(point == t.transform(t.inverted().transform(point))))
# Apply a translation, the current transform is declared invalid
t.translate(1.0, 1.0)
# The inverse is correctly updated, True
print(np.all(point == t.transform(t.inverted().transform(point))))
# Apply a translation, the current transform is declared invalid
t.translate(1.0, 1.0)
# Access to the original transform incorrectly clears invalidation
t2 = t.frozen()
# The inverse transform is never updated, False
print(np.all(point == t.transform(t.inverted().transform(point)))) |
Member
djdt
force-pushed
the
remove_get_matrix_invalid
branch
from
July 24, 2019 06:08
af100b9 to
c04a641
Compare
ruidazeng
approved these changes
Jul 26, 2019
Contributor
Author
|
@timhoffm done |
Member
|
Can you please add a test for this? I assume #14840 (comment) can be turned into one. |
timhoffm
approved these changes
Aug 12, 2019
Member
|
Thank you @djdt ! Hopefully we will hear from you again! |
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.
PR Summary
Accessing the matrix of an Affine2D transform via get_matrix sets _invalid to 0.
This can cause the transform returned by inverted() to be incorrect if the matrix is accessed between a transform and the call to inverted().
Another possible fix would be to check if invalid and set _inverted to None and _invalid to 0.
PR Checklist