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

Skip to content

FIX: fully invalidate TransformWrapper parents before swapping #25126

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 1 commit into from
Feb 2, 2023
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
16 changes: 15 additions & 1 deletion lib/matplotlib/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import matplotlib.patches as mpatches
import matplotlib.transforms as mtransforms
from matplotlib.path import Path
from matplotlib.testing.decorators import image_comparison
from matplotlib.testing.decorators import image_comparison, check_figures_equal


def test_non_affine_caching():
Expand Down Expand Up @@ -730,3 +730,17 @@ def test_transformwrapper():
r"The input and output dims of the new child \(1, 1\) "
r"do not match those of current child \(2, 2\)")):
t.set(scale.LogTransform(10))


@check_figures_equal(extensions=["png"])
def test_scale_swapping(fig_test, fig_ref):
np.random.seed(19680801)
samples = np.random.normal(size=10)
x = np.linspace(-5, 5, 10)

for fig, log_state in zip([fig_test, fig_ref], [True, False]):
ax = fig.subplots()
ax.hist(samples, log=log_state, density=True)
ax.plot(x, np.exp(-(x**2) / 2) / np.sqrt(2 * np.pi))
fig.canvas.draw()
ax.set_yscale('linear')
1 change: 1 addition & 0 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,7 @@ def set(self, child):
dimensions as the current child.
"""
if hasattr(self, "_child"): # Absent during init.
self.invalidate()
new_dims = (child.input_dims, child.output_dims)
old_dims = (self._child.input_dims, self._child.output_dims)
if new_dims != old_dims:
Expand Down