@@ -1589,14 +1589,37 @@ def test_pcolorargs():
15891589 x = np .ma .array (x , mask = (x < 0 ))
15901590 with pytest .raises (ValueError ):
15911591 ax .pcolormesh (x , y , Z [:- 1 , :- 1 ])
1592- # Expect a warning with non-increasing coordinates
1592+ # If the X or Y coords do not possess monotonicity in their respective
1593+ # directions, a warning indicating a bad grid will be triggered.
1594+ # The case of specifying coordinates by inputting 1D arrays.
15931595 x = [359 , 0 , 1 ]
15941596 y = [- 10 , 10 ]
15951597 X , Y = np .meshgrid (x , y )
15961598 Z = np .zeros (X .shape )
15971599 with pytest .warns (UserWarning ,
15981600 match = 'are not monotonically increasing or decreasing' ):
15991601 ax .pcolormesh (X , Y , Z , shading = 'auto' )
1602+ # The case of specifying coordinates by inputting 2D arrays.
1603+ x = np .linspace (- 1 , 1 , 3 )
1604+ y = np .linspace (- 1 , 1 , 3 )
1605+ X , Y = np .meshgrid (x , y )
1606+ Z = np .zeros (X .shape )
1607+ np .random .seed (19680801 )
1608+ noise_X = np .random .random (X .shape )
1609+ noise_Y = np .random .random (Y .shape )
1610+ with pytest .warns (UserWarning ,
1611+ match = 'are not monotonically increasing or '
1612+ 'decreasing' ) as record :
1613+ # Small perturbations in coordinates will not disrupt the monotonicity
1614+ # of the X-coords and Y-coords in their respective directions.
1615+ # Therefore, no warnings will be triggered.
1616+ ax .pcolormesh (X + noise_X , Y + noise_Y , Z , shading = 'auto' )
1617+ assert len (record ) == 0
1618+ # Large perturbations have disrupted the monotonicity of the X-coords
1619+ # and Y-coords in their respective directions, thus resulting in two
1620+ # bad grid warnings.
1621+ ax .pcolormesh (X + 10 * noise_X , Y + 10 * noise_Y , Z , shading = 'auto' )
1622+ assert len (record ) == 2
16001623
16011624
16021625def test_pcolormesh_underflow_error ():
0 commit comments