Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b31002

Browse files
authored
Merge pull request #14840 from djdt/remove_get_matrix_invalid
MNT: Don't assume transform is valid on access to matrix.
2 parents 76afe83 + 935f920 commit 2b31002

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/matplotlib/tests/test_transforms.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ def test_Affine2D_from_values():
176176
assert_almost_equal(actual, expected)
177177

178178

179+
def test_affine_inverted_invalidated():
180+
# Ensure that the an affine transform is not declared valid on access
181+
point = [1.0, 1.0]
182+
t = mtransforms.Affine2D()
183+
184+
assert_almost_equal(point, t.transform(t.inverted().transform(point)))
185+
# Change and access the transform
186+
t.translate(1.0, 1.0).get_matrix()
187+
assert_almost_equal(point, t.transform(t.inverted().transform(point)))
188+
189+
179190
def test_clipping_of_log():
180191
# issue 804
181192
M, L, C = Path.MOVETO, Path.LINETO, Path.CLOSEPOLY

lib/matplotlib/transforms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,9 @@ def get_matrix(self):
18751875
18761876
.
18771877
"""
1878-
self._invalid = 0
1878+
if self._invalid:
1879+
self._inverted = None
1880+
self._invalid = 0
18791881
return self._mtx
18801882

18811883
def set_matrix(self, mtx):

0 commit comments

Comments
 (0)