@@ -158,9 +158,10 @@ def setup(self) -> Generator:
158
158
plt .close ("all" )
159
159
160
160
def pass_in_axis (self , plotmethod , subplot_kw = None ) -> None :
161
- fig , axs = plt .subplots (ncols = 2 , subplot_kw = subplot_kw )
162
- plotmethod (ax = axs [0 ])
163
- assert axs [0 ].has_data ()
161
+ fig , axs = plt .subplots (ncols = 2 , subplot_kw = subplot_kw , squeeze = False )
162
+ ax = axs [0 , 0 ]
163
+ plotmethod (ax = ax )
164
+ assert ax .has_data ()
164
165
165
166
@pytest .mark .slow
166
167
def imshow_called (self , plotmethod ) -> bool :
@@ -240,9 +241,9 @@ def test_1d_x_y_kw(self) -> None:
240
241
241
242
xy : list [list [None | str ]] = [[None , None ], [None , "z" ], ["z" , None ]]
242
243
243
- f , ax = plt .subplots (3 , 1 )
244
+ f , axs = plt .subplots (3 , 1 , squeeze = False )
244
245
for aa , (x , y ) in enumerate (xy ):
245
- da .plot (x = x , y = y , ax = ax .flat [aa ])
246
+ da .plot (x = x , y = y , ax = axs .flat [aa ])
246
247
247
248
with pytest .raises (ValueError , match = r"Cannot specify both" ):
248
249
da .plot (x = "z" , y = "z" )
@@ -1566,7 +1567,9 @@ def test_colorbar_kwargs(self) -> None:
1566
1567
assert "MyLabel" in alltxt
1567
1568
assert "testvar" not in alltxt
1568
1569
# change cbar ax
1569
- fig , (ax , cax ) = plt .subplots (1 , 2 )
1570
+ fig , axs = plt .subplots (1 , 2 , squeeze = False )
1571
+ ax = axs [0 , 0 ]
1572
+ cax = axs [0 , 1 ]
1570
1573
self .plotmethod (
1571
1574
ax = ax , cbar_ax = cax , add_colorbar = True , cbar_kwargs = {"label" : "MyBar" }
1572
1575
)
@@ -1576,7 +1579,9 @@ def test_colorbar_kwargs(self) -> None:
1576
1579
assert "MyBar" in alltxt
1577
1580
assert "testvar" not in alltxt
1578
1581
# note that there are two ways to achieve this
1579
- fig , (ax , cax ) = plt .subplots (1 , 2 )
1582
+ fig , axs = plt .subplots (1 , 2 , squeeze = False )
1583
+ ax = axs [0 , 0 ]
1584
+ cax = axs [0 , 1 ]
1580
1585
self .plotmethod (
1581
1586
ax = ax , add_colorbar = True , cbar_kwargs = {"label" : "MyBar" , "cax" : cax }
1582
1587
)
@@ -3371,16 +3376,16 @@ def test_plot1d_default_rcparams() -> None:
3371
3376
# see overlapping markers:
3372
3377
fig , ax = plt .subplots (1 , 1 )
3373
3378
ds .plot .scatter (x = "A" , y = "B" , marker = "o" , ax = ax )
3374
- np .testing . assert_allclose (
3375
- ax .collections [0 ].get_edgecolor (), mpl . colors . to_rgba_array ( "w" )
3376
- )
3379
+ actual : np .ndarray = mpl . colors . to_rgba_array ( "w" )
3380
+ expected : np . ndarray = ax .collections [0 ].get_edgecolor () # type: ignore[assignment] # mpl error?
3381
+ np . testing . assert_allclose ( actual , expected )
3377
3382
3378
3383
# Facetgrids should have the default value as well:
3379
3384
fg = ds .plot .scatter (x = "A" , y = "B" , col = "x" , marker = "o" )
3380
3385
ax = fg .axs .ravel ()[0 ]
3381
- np . testing . assert_allclose (
3382
- ax .collections [0 ].get_edgecolor (), mpl . colors . to_rgba_array ( "w" )
3383
- )
3386
+ actual = mpl . colors . to_rgba_array ( "w" )
3387
+ expected = ax .collections [0 ].get_edgecolor () # type: ignore[assignment] # mpl error?
3388
+ np . testing . assert_allclose ( actual , expected )
3384
3389
3385
3390
# scatter should not emit any warnings when using unfilled markers:
3386
3391
with assert_no_warnings ():
@@ -3390,9 +3395,9 @@ def test_plot1d_default_rcparams() -> None:
3390
3395
# Prioritize edgecolor argument over default plot1d values:
3391
3396
fig , ax = plt .subplots (1 , 1 )
3392
3397
ds .plot .scatter (x = "A" , y = "B" , marker = "o" , ax = ax , edgecolor = "k" )
3393
- np . testing . assert_allclose (
3394
- ax .collections [0 ].get_edgecolor (), mpl . colors . to_rgba_array ( "k" )
3395
- )
3398
+ actual = mpl . colors . to_rgba_array ( "k" )
3399
+ expected = ax .collections [0 ].get_edgecolor () # type: ignore[assignment] # mpl error?
3400
+ np . testing . assert_allclose ( actual , expected )
3396
3401
3397
3402
3398
3403
@requires_matplotlib
0 commit comments