12
12
import matplotlib .path as mpath
13
13
import matplotlib .transforms as mtransforms
14
14
from matplotlib .collections import (Collection , LineCollection ,
15
- EventCollection , PolyCollection ,
16
- QuadMesh )
15
+ EventCollection , PolyCollection )
17
16
from matplotlib .testing .decorators import check_figures_equal , image_comparison
18
- from matplotlib ._api .deprecation import MatplotlibDeprecationWarning
19
17
20
18
21
19
def generate_EventCollection_plot ():
@@ -811,77 +809,6 @@ def test_autolim_with_zeros(transform, expected):
811
809
np .testing .assert_allclose (ax .get_xlim (), expected )
812
810
813
811
814
- @pytest .mark .parametrize ('flat_ref, kwargs' , [
815
- (True , {}),
816
- (False , {}),
817
- (True , dict (antialiased = False )),
818
- (False , dict (transform = '__initialization_delayed__' )),
819
- ])
820
- @check_figures_equal (extensions = ['png' ])
821
- def test_quadmesh_deprecated_signature (
822
- fig_test , fig_ref , flat_ref , kwargs ):
823
- # test that the new and old quadmesh signature produce the same results
824
- # remove when the old QuadMesh.__init__ signature expires (v3.5+2)
825
- x = [0 , 1 , 2 , 3. ]
826
- y = [1 , 2 , 3. ]
827
- X , Y = np .meshgrid (x , y )
828
- X += 0.2 * Y
829
- coords = np .stack ([X , Y ], axis = - 1 )
830
- assert coords .shape == (3 , 4 , 2 )
831
- C = np .linspace (0 , 2 , 6 ).reshape (2 , 3 )
832
-
833
- ax = fig_test .add_subplot ()
834
- ax .set (xlim = (0 , 5 ), ylim = (0 , 4 ))
835
- if 'transform' in kwargs :
836
- kwargs ['transform' ] = mtransforms .Affine2D ().scale (1.2 ) + ax .transData
837
- qmesh = QuadMesh (coords , ** kwargs )
838
- qmesh .set_array (C )
839
- ax .add_collection (qmesh )
840
- assert qmesh ._shading == 'flat'
841
-
842
- ax = fig_ref .add_subplot ()
843
- ax .set (xlim = (0 , 5 ), ylim = (0 , 4 ))
844
- if 'transform' in kwargs :
845
- kwargs ['transform' ] = mtransforms .Affine2D ().scale (1.2 ) + ax .transData
846
- with pytest .warns (MatplotlibDeprecationWarning ):
847
- qmesh = QuadMesh (4 - 1 , 3 - 1 ,
848
- coords .copy ().reshape (- 1 , 2 ) if flat_ref else coords ,
849
- ** kwargs )
850
- qmesh .set_array (C .flatten () if flat_ref else C )
851
- ax .add_collection (qmesh )
852
- assert qmesh ._shading == 'flat'
853
-
854
-
855
- @check_figures_equal (extensions = ['png' ])
856
- def test_quadmesh_deprecated_positional (fig_test , fig_ref ):
857
- # test that positional parameters are still accepted with the old signature
858
- # and work correctly
859
- # remove when the old QuadMesh.__init__ signature expires (v3.5+2)
860
- from matplotlib .collections import QuadMesh
861
-
862
- x = [0 , 1 , 2 , 3. ]
863
- y = [1 , 2 , 3. ]
864
- X , Y = np .meshgrid (x , y )
865
- X += 0.2 * Y
866
- coords = np .stack ([X , Y ], axis = - 1 )
867
- assert coords .shape == (3 , 4 , 2 )
868
- C = np .linspace (0 , 2 , 12 ).reshape (3 , 4 )
869
-
870
- ax = fig_test .add_subplot ()
871
- ax .set (xlim = (0 , 5 ), ylim = (0 , 4 ))
872
- qmesh = QuadMesh (coords , antialiased = False , shading = 'gouraud' )
873
- qmesh .set_array (C )
874
- ax .add_collection (qmesh )
875
-
876
- ax = fig_ref .add_subplot ()
877
- ax .set (xlim = (0 , 5 ), ylim = (0 , 4 ))
878
- with pytest .warns (MatplotlibDeprecationWarning ):
879
- qmesh = QuadMesh (4 - 1 , 3 - 1 , coords .copy ().reshape (- 1 , 2 ),
880
- False , 'gouraud' )
881
- qmesh .set_array (C )
882
- ax .add_collection (qmesh )
883
-
884
-
885
812
def test_quadmesh_set_array_validation ():
886
813
x = np .arange (11 )
887
814
y = np .arange (8 )
@@ -890,7 +817,9 @@ def test_quadmesh_set_array_validation():
890
817
coll = ax .pcolormesh (x , y , z )
891
818
892
819
# Test deprecated warning when faulty shape is passed.
893
- with pytest .warns (MatplotlibDeprecationWarning ):
820
+ with pytest .raises (ValueError , match = r"For X \(11\) and Y \(8\) with flat "
821
+ r"shading, the expected shape of A is \(7, 10\), not "
822
+ r"\(10, 7\)" ):
894
823
coll .set_array (z .reshape (10 , 7 ))
895
824
896
825
z = np .arange (54 ).reshape ((6 , 9 ))
0 commit comments