@@ -376,10 +376,9 @@ def test_image_grid():
376
376
377
377
fig = plt .figure (1 , (4 , 4 ))
378
378
grid = ImageGrid (fig , 111 , nrows_ncols = (2 , 2 ), axes_pad = 0.1 )
379
-
379
+ assert grid . get_axes_pad () == ( 0.1 , 0.1 )
380
380
for i in range (4 ):
381
381
grid [i ].imshow (im , interpolation = 'nearest' )
382
- grid [i ].set_title ('test {0}{0}' .format (i ))
383
382
384
383
385
384
def test_gettightbbox ():
@@ -492,6 +491,7 @@ def test_grid_axes_lists():
492
491
assert_array_equal (grid , grid .axes_all )
493
492
assert_array_equal (grid .axes_row , np .transpose (grid .axes_column ))
494
493
assert_array_equal (grid , np .ravel (grid .axes_row ), "row" )
494
+ assert grid .get_geometry () == (2 , 3 )
495
495
grid = Grid (fig , 111 , (2 , 3 ), direction = "column" )
496
496
assert_array_equal (grid , np .ravel (grid .axes_column ), "column" )
497
497
@@ -507,6 +507,17 @@ def test_grid_axes_position(direction):
507
507
assert loc [3 ]._nx == loc [1 ]._nx and loc [3 ]._ny == loc [2 ]._ny
508
508
509
509
510
+ @pytest .mark .parametrize ('rect, ngrids, error, message' , (
511
+ ((1 , 1 ), None , TypeError , "Incorrect rect format" ),
512
+ (111 , - 1 , ValueError , "ngrids must be positive" ),
513
+ (111 , 7 , ValueError , "ngrids must be positive" ),
514
+ ))
515
+ def test_grid_errors (rect , ngrids , error , message ):
516
+ fig = plt .figure ()
517
+ with pytest .raises (error , match = message ):
518
+ Grid (fig , rect , (2 , 3 ), ngrids = ngrids )
519
+
520
+
510
521
@check_figures_equal (extensions = ["png" ])
511
522
def test_mark_inset_unstales_viewlim (fig_test , fig_ref ):
512
523
inset , full = fig_test .subplots (1 , 2 )
0 commit comments