From 7a1df7830f7685a99291d90c5e79bfc5e7876f31 Mon Sep 17 00:00:00 2001 From: saranti Date: Sat, 26 Nov 2022 16:39:46 +1100 Subject: [PATCH 1/2] Test that plot results aren't affected by mutating input arrays --- lib/mpl_toolkits/mplot3d/tests/test_axes3d.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py index aad42d1f4d72..db6927f78301 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py @@ -2124,3 +2124,37 @@ def test_panecolor_rcparams(): 'axes3d.zaxis.panecolor': 'b'}): fig = plt.figure(figsize=(1, 1)) fig.add_subplot(projection='3d') + + +@check_figures_equal(extensions=["png"]) +def test_mutating_input_arrays_y_and_z(fig_test, fig_ref): + """ + Test to see if the `z` axis does not get mutated + after a call to `Axes3D.plot` + + test cases came from GH#8990 + """ + ax1 = fig_test.add_subplot(111, projection='3d') + x = [1, 2, 3] + y = [0.0, 0.0, 0.0] + z = [0.0, 0.0, 0.0] + ax1.plot(x, y, z, 'o-') + + ax1.set_ylim([0, 4]) + ax1.set_zlim([0, 4]) + fig_test.draw_without_rendering() + + # mutate y,z to get a nontrivial line + y[:] = [1, 2, 3] + z[:] = [1, 2, 3] + + # draw the same plot without mutating x and y + ax2 = fig_ref.add_subplot(111, projection='3d') + x = [1, 2, 3] + y = [0.0, 0.0, 0.0] + z = [0.0, 0.0, 0.0] + ax2.plot(x, y, z, 'o-') + + ax2.set_ylim([0, 4]) + ax2.set_zlim([0, 4]) + fig_test.draw_without_rendering() From a30a64e54bd24362977b7d2bff6becce3b676cbb Mon Sep 17 00:00:00 2001 From: saranti Date: Sat, 26 Nov 2022 19:55:17 +1100 Subject: [PATCH 2/2] Test that plot results aren't affected by mutating input arrays --- lib/mpl_toolkits/mplot3d/tests/test_axes3d.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py index db6927f78301..ef330a027681 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py @@ -2140,10 +2140,6 @@ def test_mutating_input_arrays_y_and_z(fig_test, fig_ref): z = [0.0, 0.0, 0.0] ax1.plot(x, y, z, 'o-') - ax1.set_ylim([0, 4]) - ax1.set_zlim([0, 4]) - fig_test.draw_without_rendering() - # mutate y,z to get a nontrivial line y[:] = [1, 2, 3] z[:] = [1, 2, 3] @@ -2154,7 +2150,3 @@ def test_mutating_input_arrays_y_and_z(fig_test, fig_ref): y = [0.0, 0.0, 0.0] z = [0.0, 0.0, 0.0] ax2.plot(x, y, z, 'o-') - - ax2.set_ylim([0, 4]) - ax2.set_zlim([0, 4]) - fig_test.draw_without_rendering()