@@ -1376,3 +1376,43 @@ def test_rgba_antialias():
1376
1376
# alternating red and blue stripes become purple
1377
1377
axs [3 ].imshow (aa , interpolation = 'antialiased' , interpolation_stage = 'rgba' ,
1378
1378
cmap = cmap , vmin = - 1.2 , vmax = 1.2 )
1379
+
1380
+
1381
+ # We check for the warning with a draw() in the test, but we also need to
1382
+ # filter the warning as it is emitted by the figure test decorator
1383
+ @pytest .mark .filterwarnings (r'ignore:Data with more than .* '
1384
+ 'cannot be accurately displayed' )
1385
+ @pytest .mark .parametrize ('origin' , ['upper' , 'lower' ])
1386
+ @pytest .mark .parametrize (
1387
+ 'dim, size, msg' , [['row' , 2 ** 23 , r'2\*\*23 rows' ],
1388
+ ['col' , 2 ** 24 , r'2\*\*24 columns' ]])
1389
+ @check_figures_equal (extensions = ('png' , ))
1390
+ def test_large_image (fig_test , fig_ref , dim , size , msg , origin ):
1391
+ # Check that Matplotlib downsamples images that are too big for AGG
1392
+ # See issue #19276. Currently the fix only works for png output but not
1393
+ # pdf or svg output.
1394
+ ax_test = fig_test .subplots ()
1395
+ ax_ref = fig_ref .subplots ()
1396
+
1397
+ array = np .zeros ((1 , size + 2 ))
1398
+ array [:, array .size // 2 :] = 1
1399
+ if dim == 'col' :
1400
+ array = array .T
1401
+ im = ax_test .imshow (array , vmin = 0 , vmax = 1 ,
1402
+ aspect = 'auto' , extent = (0 , 1 , 0 , 1 ),
1403
+ interpolation = 'none' ,
1404
+ origin = origin )
1405
+
1406
+ with pytest .warns (UserWarning ,
1407
+ match = f'Data with more than { msg } cannot be '
1408
+ 'accurately displayed.' ):
1409
+ fig_test .canvas .draw ()
1410
+
1411
+ array = np .zeros ((1 , 2 ))
1412
+ array [:, 1 ] = 1
1413
+ if dim == 'col' :
1414
+ array = array .T
1415
+ im = ax_ref .imshow (array , vmin = 0 , vmax = 1 , aspect = 'auto' ,
1416
+ extent = (0 , 1 , 0 , 1 ),
1417
+ interpolation = 'none' ,
1418
+ origin = origin )
0 commit comments