@@ -698,6 +698,35 @@ def test_singleton_autolim():
698
698
np .testing .assert_allclose (ax .get_xlim (), [- 0.06 , 0.06 ])
699
699
700
700
701
+ def test_quadmesh_set_array_validation ():
702
+ x = np .arange (4 )
703
+ y = np .arange (4 )
704
+ z = np .arange (9 ).reshape ((3 , 3 ))
705
+ fig , ax = plt .subplots ()
706
+ coll = ax .pcolormesh (x , y , np .ones (z .shape ))
707
+ z = np .arange (16 ).reshape ((4 , 4 ))
708
+
709
+ with pytest .raises (ValueError , match = "Dimensions of A (4, 4) are incompatible with X (3) and/or Y (3)" ):
710
+ coll .set_array (z )
711
+ with pytest .raises (ValueError , match = "Dimensions of A (16,) are incompatible with X (3) and/or Y (3)" ):
712
+ coll .set_array (z .ravel ())
713
+
714
+ fig , ax = plt .subplots ()
715
+ coll = ax .pcolormesh (x , y , np .ones (z .shape ), shading = 'nearest' )
716
+ with pytest .raises (ValueError , match = "Dimensions of A (3, 3) are incompatible with X (4) and/or Y (4)" ):
717
+ z = np .arange (9 ).reshape ((3 , 3 ))
718
+ coll .set_array (z )
719
+
720
+ x = np .arange (3 )
721
+ y = np .arange (3 )
722
+ z = np .arange (9 ).reshape ((3 , 3 ))
723
+ fig , ax = plt .subplots ()
724
+ coll = ax .pcolormesh (x , y , np .ones (z .shape ), shading = 'gouraud' )
725
+ z = np .arange (16 ).reshape ((4 , 4 ))
726
+ with pytest .raises (ValueError , match = "Dimensions of A (4, 4) are incompatible with X (2) and/or Y (2)" ):
727
+ coll .set_array (z )
728
+
729
+
701
730
def test_quadmesh_set_array ():
702
731
x = np .arange (4 )
703
732
y = np .arange (4 )
0 commit comments