diff --git a/lib/matplotlib/tests/test_transforms.py b/lib/matplotlib/tests/test_transforms.py index 410eb2607430..b0cb3b653c7b 100644 --- a/lib/matplotlib/tests/test_transforms.py +++ b/lib/matplotlib/tests/test_transforms.py @@ -176,6 +176,17 @@ def test_Affine2D_from_values(): assert_almost_equal(actual, expected) +def test_affine_inverted_invalidated(): + # Ensure that the an affine transform is not declared valid on access + point = [1.0, 1.0] + t = mtransforms.Affine2D() + + assert_almost_equal(point, t.transform(t.inverted().transform(point))) + # Change and access the transform + t.translate(1.0, 1.0).get_matrix() + assert_almost_equal(point, t.transform(t.inverted().transform(point))) + + def test_clipping_of_log(): # issue 804 M, L, C = Path.MOVETO, Path.LINETO, Path.CLOSEPOLY diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index ce126c81ea73..9f50e9c91cc2 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -1850,7 +1850,9 @@ def get_matrix(self): . """ - self._invalid = 0 + if self._invalid: + self._inverted = None + self._invalid = 0 return self._mtx def set_matrix(self, mtx):