From fc70e192031a21ef74e901ef776412f1bfaad76f Mon Sep 17 00:00:00 2001 From: jeffreypaul15 Date: Sat, 29 May 2021 10:01:34 +0530 Subject: [PATCH 1/3] Replaces default value of shading from False to 'flat' in Quadmesh --- lib/matplotlib/collections.py | 4 ++-- lib/matplotlib/tests/test_collections.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 1f88bbef3e4f..ee9058e9f52a 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -2002,7 +2002,7 @@ def __init__(self, *args, **kwargs): # The following raises a TypeError iif the args don't match. w, h, coords, antialiased, shading, kwargs = ( lambda meshWidth, meshHeight, coordinates, antialiased=True, - shading=False, **kwargs: + shading='flat', **kwargs: (meshWidth, meshHeight, coordinates, antialiased, shading, kwargs))(*args, **kwargs) except TypeError as exc: @@ -2010,7 +2010,7 @@ def __init__(self, *args, **kwargs): # If the following raises a TypeError (i.e. args don't match), # just let it propagate. coords, antialiased, shading, kwargs = ( - lambda coordinates, antialiased=True, shading=False, **kwargs: + lambda coordinates, antialiased=True, shading='flat', **kwargs: (coordinates, antialiased, shading, kwargs))(*args, **kwargs) coords = np.asarray(coords, np.float64) else: # The old signature matched. diff --git a/lib/matplotlib/tests/test_collections.py b/lib/matplotlib/tests/test_collections.py index 12d26752f80f..411ff72b9053 100644 --- a/lib/matplotlib/tests/test_collections.py +++ b/lib/matplotlib/tests/test_collections.py @@ -744,6 +744,8 @@ def test_quadmesh_deprecated_signature( qmesh.set_array(C) ax.add_collection(qmesh) + assert qmesh._shading == 'flat' + ax = fig_ref.add_subplot() ax.set(xlim=(0, 5), ylim=(0, 4)) if 'transform' in kwargs: From d319a96c20a89cc1f4f3c8e3f75c4b54d924f87a Mon Sep 17 00:00:00 2001 From: jeffreypaul15 Date: Sat, 29 May 2021 10:05:55 +0530 Subject: [PATCH 2/3] updated previous changelog entry --- doc/api/next_api_changes/deprecations/20237-TH.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/next_api_changes/deprecations/20237-TH.rst b/doc/api/next_api_changes/deprecations/20237-TH.rst index 2120fb9b9bef..435986f94f0f 100644 --- a/doc/api/next_api_changes/deprecations/20237-TH.rst +++ b/doc/api/next_api_changes/deprecations/20237-TH.rst @@ -3,11 +3,11 @@ QuadMesh signature The ``QuadMesh`` signature :: def __init__(meshWidth, meshHeight, coordinates, - antialiased=True, shading=False, **kwargs) + antialiased=True, shading='flat', **kwargs) is deprecated and replaced by the new signature :: - def __init__(coordinates, *, antialiased=True, shading=False, **kwargs) + def __init__(coordinates, *, antialiased=True, shading='flat', **kwargs) In particular: From 95f40030f1479718adfc99bfa216e2d85b682978 Mon Sep 17 00:00:00 2001 From: jeffreypaul15 Date: Sat, 29 May 2021 10:09:11 +0530 Subject: [PATCH 3/3] Updated tests to check for default value of shading --- lib/matplotlib/tests/test_collections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_collections.py b/lib/matplotlib/tests/test_collections.py index 411ff72b9053..3a12f2fc3fc1 100644 --- a/lib/matplotlib/tests/test_collections.py +++ b/lib/matplotlib/tests/test_collections.py @@ -743,7 +743,6 @@ def test_quadmesh_deprecated_signature( qmesh = QuadMesh(coords, **kwargs) qmesh.set_array(C) ax.add_collection(qmesh) - assert qmesh._shading == 'flat' ax = fig_ref.add_subplot() @@ -756,6 +755,7 @@ def test_quadmesh_deprecated_signature( **kwargs) qmesh.set_array(C.flatten() if flat_ref else C) ax.add_collection(qmesh) + assert qmesh._shading == 'flat' @check_figures_equal(extensions=['png'])