1
1
import io
2
2
from typing import Any
3
3
4
+ from matplotlib .axes import Axes
5
+ from matplotlib .figure import Figure
4
6
import matplotlib .pyplot as plt
5
7
from matplotlib .table import Table
6
8
import numpy as np
@@ -178,26 +180,26 @@ def close_figures():
178
180
179
181
180
182
def test_andrews_curves (close_figures ) -> None :
181
- check (assert_type (pd .plotting .andrews_curves (IRIS_DF , "Name" ), plt . Axes ), plt . Axes )
183
+ check (assert_type (pd .plotting .andrews_curves (IRIS_DF , "Name" ), Axes ), Axes )
182
184
183
185
184
186
def test_autocorrelation_plot (close_figures ) -> None :
185
187
spacing = np .linspace (- 9 * np .pi , 9 * np .pi , num = 1000 )
186
188
s = pd .Series (0.7 * np .random .rand (1000 ) + 0.3 * np .sin (spacing ))
187
- check (assert_type (pd .plotting .autocorrelation_plot (s ), plt . Axes ), plt . Axes )
189
+ check (assert_type (pd .plotting .autocorrelation_plot (s ), Axes ), Axes )
188
190
189
191
190
192
def test_bootstrap_plot (close_figures ) -> None :
191
193
s = pd .Series (np .random .uniform (size = 100 ))
192
- check (assert_type (pd .plotting .bootstrap_plot (s ), plt . Figure ), plt . Figure )
194
+ check (assert_type (pd .plotting .bootstrap_plot (s ), Figure ), Figure )
193
195
194
196
195
197
def test_boxplot (close_figures ) -> None :
196
198
np .random .seed (1234 )
197
199
df = pd .DataFrame (np .random .randn (10 , 4 ), columns = ["Col1" , "Col2" , "Col3" , "Col4" ])
198
200
check (
199
- assert_type (pd .plotting .boxplot (df , column = ["Col1" , "Col2" , "Col3" ]), plt . Axes ),
200
- plt . Axes ,
201
+ assert_type (pd .plotting .boxplot (df , column = ["Col1" , "Col2" , "Col3" ]), Axes ),
202
+ Axes ,
201
203
)
202
204
203
205
@@ -210,7 +212,7 @@ def test_lag_plot(close_figures) -> None:
210
212
np .random .seed (5 )
211
213
x = np .cumsum (np .random .normal (loc = 1 , scale = 5 , size = 50 ))
212
214
s = pd .Series (x )
213
- check (assert_type (pd .plotting .lag_plot (s , lag = 1 ), plt . Axes ), plt . Axes )
215
+ check (assert_type (pd .plotting .lag_plot (s , lag = 1 ), Axes ), Axes )
214
216
215
217
216
218
def test_plot_parallel_coordinates (close_figures ) -> None :
@@ -219,9 +221,9 @@ def test_plot_parallel_coordinates(close_figures) -> None:
219
221
pd .plotting .parallel_coordinates (
220
222
IRIS_DF , "Name" , color = ("#556270" , "#4ECDC4" , "#C7F464" )
221
223
),
222
- plt . Axes ,
224
+ Axes ,
223
225
),
224
- plt . Axes ,
226
+ Axes ,
225
227
)
226
228
227
229
@@ -250,7 +252,7 @@ def test_radviz(close_figures) -> None:
250
252
],
251
253
}
252
254
)
253
- check (assert_type (pd .plotting .radviz (df , "Category" ), plt . Axes ), plt . Axes )
255
+ check (assert_type (pd .plotting .radviz (df , "Category" ), Axes ), Axes )
254
256
255
257
256
258
def test_scatter_matrix (close_figures ) -> None :
@@ -271,9 +273,9 @@ def test_table(close_figures) -> None:
271
273
272
274
273
275
def test_plot_line ():
274
- check (assert_type (IRIS_DF .plot (), plt . Axes ), plt . Axes )
275
- check (assert_type (IRIS_DF .plot .line (), plt . Axes ), plt . Axes )
276
- check (assert_type (IRIS_DF .plot (kind = "line" ), plt . Axes ), plt . Axes )
276
+ check (assert_type (IRIS_DF .plot (), Axes ), Axes )
277
+ check (assert_type (IRIS_DF .plot .line (), Axes ), Axes )
278
+ check (assert_type (IRIS_DF .plot (kind = "line" ), Axes ), Axes )
277
279
check (
278
280
assert_type (
279
281
IRIS_DF .plot .line (subplots = True ),
@@ -291,8 +293,8 @@ def test_plot_line():
291
293
292
294
293
295
def test_plot_area (close_figures ) -> None :
294
- check (assert_type (IRIS_DF .plot .area (), plt . Axes ), plt . Axes )
295
- check (assert_type (IRIS_DF .plot (kind = "area" ), plt . Axes ), plt . Axes )
296
+ check (assert_type (IRIS_DF .plot .area (), Axes ), Axes )
297
+ check (assert_type (IRIS_DF .plot (kind = "area" ), Axes ), Axes )
296
298
check (
297
299
assert_type (
298
300
IRIS_DF .plot .area (subplots = True ),
@@ -310,8 +312,8 @@ def test_plot_area(close_figures) -> None:
310
312
311
313
312
314
def test_plot_bar (close_figures ) -> None :
313
- check (assert_type (IRIS_DF .plot .bar (), plt . Axes ), plt . Axes )
314
- check (assert_type (IRIS_DF .plot (kind = "bar" ), plt . Axes ), plt . Axes )
315
+ check (assert_type (IRIS_DF .plot .bar (), Axes ), Axes )
316
+ check (assert_type (IRIS_DF .plot (kind = "bar" ), Axes ), Axes )
315
317
check (
316
318
assert_type (
317
319
IRIS_DF .plot .bar (subplots = True ),
@@ -329,8 +331,8 @@ def test_plot_bar(close_figures) -> None:
329
331
330
332
331
333
def test_plot_barh (close_figures ) -> None :
332
- check (assert_type (IRIS_DF .plot .barh (), plt . Axes ), plt . Axes )
333
- check (assert_type (IRIS_DF .plot (kind = "barh" ), plt . Axes ), plt . Axes )
334
+ check (assert_type (IRIS_DF .plot .barh (), Axes ), Axes )
335
+ check (assert_type (IRIS_DF .plot (kind = "barh" ), Axes ), Axes )
334
336
check (
335
337
assert_type (
336
338
IRIS_DF .plot .barh (subplots = True ),
@@ -348,8 +350,8 @@ def test_plot_barh(close_figures) -> None:
348
350
349
351
350
352
def test_plot_box (close_figures ) -> None :
351
- check (assert_type (IRIS_DF .plot .box (), plt . Axes ), plt . Axes )
352
- check (assert_type (IRIS_DF .plot (kind = "box" ), plt . Axes ), plt . Axes )
353
+ check (assert_type (IRIS_DF .plot .box (), Axes ), Axes )
354
+ check (assert_type (IRIS_DF .plot (kind = "box" ), Axes ), Axes )
353
355
check (
354
356
assert_type (
355
357
IRIS_DF .plot .box (subplots = True ),
@@ -367,8 +369,8 @@ def test_plot_box(close_figures) -> None:
367
369
368
370
369
371
def test_plot_density (close_figures ) -> None :
370
- check (assert_type (IRIS_DF .plot .density (), plt . Axes ), plt . Axes )
371
- check (assert_type (IRIS_DF .plot (kind = "density" ), plt . Axes ), plt . Axes )
372
+ check (assert_type (IRIS_DF .plot .density (), Axes ), Axes )
373
+ check (assert_type (IRIS_DF .plot (kind = "density" ), Axes ), Axes )
372
374
check (
373
375
assert_type (
374
376
IRIS_DF .plot .density (subplots = True ),
@@ -387,14 +389,12 @@ def test_plot_density(close_figures) -> None:
387
389
388
390
def test_plot_hexbin (close_figures ) -> None :
389
391
check (
390
- assert_type (IRIS_DF .plot .hexbin (x = "SepalLength" , y = "SepalWidth" ), plt . Axes ),
391
- plt . Axes ,
392
+ assert_type (IRIS_DF .plot .hexbin (x = "SepalLength" , y = "SepalWidth" ), Axes ),
393
+ Axes ,
392
394
)
393
395
check (
394
- assert_type (
395
- IRIS_DF .plot (x = "SepalLength" , y = "SepalWidth" , kind = "hexbin" ), plt .Axes
396
- ),
397
- plt .Axes ,
396
+ assert_type (IRIS_DF .plot (x = "SepalLength" , y = "SepalWidth" , kind = "hexbin" ), Axes ),
397
+ Axes ,
398
398
)
399
399
check (
400
400
assert_type (
@@ -413,8 +413,8 @@ def test_plot_hexbin(close_figures) -> None:
413
413
414
414
415
415
def test_plot_hist (close_figures ) -> None :
416
- check (assert_type (IRIS_DF .plot .hist (), plt . Axes ), plt . Axes )
417
- check (assert_type (IRIS_DF .plot (kind = "hist" ), plt . Axes ), plt . Axes )
416
+ check (assert_type (IRIS_DF .plot .hist (), Axes ), Axes )
417
+ check (assert_type (IRIS_DF .plot (kind = "hist" ), Axes ), Axes )
418
418
check (
419
419
assert_type (
420
420
IRIS_DF .plot .hist (subplots = True ),
@@ -432,8 +432,8 @@ def test_plot_hist(close_figures) -> None:
432
432
433
433
434
434
def test_plot_kde (close_figures ) -> None :
435
- check (assert_type (IRIS_DF .plot .kde (), plt . Axes ), plt . Axes )
436
- check (assert_type (IRIS_DF .plot (kind = "kde" ), plt . Axes ), plt . Axes )
435
+ check (assert_type (IRIS_DF .plot .kde (), Axes ), Axes )
436
+ check (assert_type (IRIS_DF .plot (kind = "kde" ), Axes ), Axes )
437
437
check (
438
438
assert_type (
439
439
IRIS_DF .plot .kde (subplots = True ),
@@ -451,8 +451,8 @@ def test_plot_kde(close_figures) -> None:
451
451
452
452
453
453
def test_plot_pie (close_figures ) -> None :
454
- check (assert_type (IRIS_DF .plot .pie (y = "SepalLength" ), plt . Axes ), plt . Axes )
455
- check (assert_type (IRIS_DF .plot (kind = "pie" , y = "SepalLength" ), plt . Axes ), plt . Axes )
454
+ check (assert_type (IRIS_DF .plot .pie (y = "SepalLength" ), Axes ), Axes )
455
+ check (assert_type (IRIS_DF .plot (kind = "pie" , y = "SepalLength" ), Axes ), Axes )
456
456
check (
457
457
assert_type (
458
458
IRIS_DF .plot .pie (y = "SepalLength" , subplots = True ),
@@ -472,14 +472,14 @@ def test_plot_pie(close_figures) -> None:
472
472
473
473
def test_plot_scatter (close_figures ) -> None :
474
474
check (
475
- assert_type (IRIS_DF .plot .scatter (x = "SepalLength" , y = "SepalWidth" ), plt . Axes ),
476
- plt . Axes ,
475
+ assert_type (IRIS_DF .plot .scatter (x = "SepalLength" , y = "SepalWidth" ), Axes ),
476
+ Axes ,
477
477
)
478
478
check (
479
479
assert_type (
480
- IRIS_DF .plot (x = "SepalLength" , y = "SepalWidth" , kind = "scatter" ), plt . Axes
480
+ IRIS_DF .plot (x = "SepalLength" , y = "SepalWidth" , kind = "scatter" ), Axes
481
481
),
482
- plt . Axes ,
482
+ Axes ,
483
483
)
484
484
check (
485
485
assert_type (
@@ -538,9 +538,9 @@ def test_plot_keywords(close_figures):
538
538
include_bool = True ,
539
539
backend = "matplotlib" ,
540
540
),
541
- plt . Axes ,
541
+ Axes ,
542
542
),
543
- plt . Axes ,
543
+ Axes ,
544
544
)
545
545
546
546
df = pd .DataFrame (np .random .rand (50 , 4 ), columns = ["a" , "b" , "c" , "d" ])
@@ -558,17 +558,15 @@ def test_plot_keywords(close_figures):
558
558
s = 50 ,
559
559
colorbar = False ,
560
560
),
561
- plt . Axes ,
561
+ Axes ,
562
562
),
563
- plt . Axes ,
563
+ Axes ,
564
564
)
565
565
566
566
df = pd .DataFrame (np .random .rand (10 , 5 ), columns = ["A" , "B" , "C" , "D" , "E" ])
567
567
check (
568
- assert_type (
569
- df .plot (kind = "box" , vert = False , positions = [1 , 4 , 5 , 6 , 8 ]), plt .Axes
570
- ),
571
- plt .Axes ,
568
+ assert_type (df .plot (kind = "box" , vert = False , positions = [1 , 4 , 5 , 6 , 8 ]), Axes ),
569
+ Axes ,
572
570
)
573
571
574
572
0 commit comments