Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

FIX: Made AffineDeltaTransform pass-through properly #28375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 5 doc/api/next_api_changes/behavior/28375-MP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``transforms.AffineDeltaTransform`` updates correctly on axis limit changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Before this change, transform sub-graphs with ``AffineDeltaTransform`` did not update correctly.
This PR ensures that changes to the child transform are passed through correctly.
25 changes: 25 additions & 0 deletions 25 lib/matplotlib/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,31 @@ def test_deepcopy(self):
assert_array_equal(s.get_matrix(), a.get_matrix())


class TestAffineDeltaTransform:
def test_invalidate(self):
before = np.array([[1.0, 4.0, 0.0],
[5.0, 1.0, 0.0],
[0.0, 0.0, 1.0]])
after = np.array([[1.0, 3.0, 0.0],
[5.0, 1.0, 0.0],
[0.0, 0.0, 1.0]])

# Translation and skew present
base = mtransforms.Affine2D.from_values(1, 5, 4, 1, 2, 3)
t = mtransforms.AffineDeltaTransform(base)
assert_array_equal(t.get_matrix(), before)

# Mess with the internal structure of `base` without invalidating
# This should not affect this transform because it's a passthrough:
# it's always invalid
base.get_matrix()[0, 1:] = 3
assert_array_equal(t.get_matrix(), after)

# Invalidate the base
base.invalidate()
assert_array_equal(t.get_matrix(), after)


def test_non_affine_caching():
class AssertingNonAffineTransform(mtransforms.Transform):
"""
Expand Down
3 changes: 3 additions & 0 deletions 3 lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2711,9 +2711,12 @@ class AffineDeltaTransform(Affine2DBase):
This class is experimental as of 3.3, and the API may change.
"""

pass_through = True

def __init__(self, transform, **kwargs):
super().__init__(**kwargs)
self._base_transform = transform
self.set_children(transform)

__str__ = _make_str_method("_base_transform")

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.