From 4a1ef78e4cb5f9d4463356e7076f68d823696cc0 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 16 Aug 2023 10:43:09 +0200 Subject: [PATCH] Backport PR #26532: Fix input check in Poly3DCollection.__init__ (cherry picked from commit 267b7c08bf39ea2d40ff348e6d7eddf218e94c74) --- lib/mpl_toolkits/mplot3d/art3d.py | 2 +- lib/mpl_toolkits/mplot3d/tests/test_axes3d.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index b0e27a30618c..5df5c8271e7f 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -880,7 +880,7 @@ def __init__(self, verts, *args, zsort='average', shade=False, kwargs['edgecolors'] = _shade_colors( edgecolors, normals, lightsource ) - if facecolors is None and edgecolors in None: + if facecolors is None and edgecolors is None: raise ValueError( "You must provide facecolors, edgecolors, or both for " "shade to work.") diff --git a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py index a618ee7a803d..e4c2053dc072 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py @@ -2176,3 +2176,13 @@ 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-') + + +def test_Poly3DCollection_init_value_error(): + # smoke test to ensure the input check works + # GH#26420 + with pytest.raises(ValueError, + match='You must provide facecolors, edgecolors, ' + 'or both for shade to work.'): + poly = np.array([[0, 0, 1], [0, 1, 1], [0, 0, 0]], float) + c = art3d.Poly3DCollection([poly], shade=True) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy