21
21
from pandas .io .formats .printing import pprint_thing
22
22
import pandas .plotting as plotting
23
23
24
+ pytestmark = pytest .mark .slow
25
+
24
26
25
27
@td .skip_if_no_mpl
26
28
class TestDataFramePlots (TestPlotBase ):
@@ -39,7 +41,6 @@ def setup_method(self, method):
39
41
}
40
42
)
41
43
42
- @pytest .mark .slow
43
44
def test_plot (self ):
44
45
from pandas .plotting ._matplotlib .compat import mpl_ge_3_1_0
45
46
@@ -171,21 +172,18 @@ def test_nonnumeric_exclude(self):
171
172
ax = df .plot ()
172
173
assert len (ax .get_lines ()) == 1 # B was plotted
173
174
174
- @pytest .mark .slow
175
175
def test_implicit_label (self ):
176
176
df = DataFrame (np .random .randn (10 , 3 ), columns = ["a" , "b" , "c" ])
177
177
ax = df .plot (x = "a" , y = "b" )
178
178
self ._check_text_labels (ax .xaxis .get_label (), "a" )
179
179
180
- @pytest .mark .slow
181
180
def test_donot_overwrite_index_name (self ):
182
181
# GH 8494
183
182
df = DataFrame (np .random .randn (2 , 2 ), columns = ["a" , "b" ])
184
183
df .index .name = "NAME"
185
184
df .plot (y = "b" , label = "LABEL" )
186
185
assert df .index .name == "NAME"
187
186
188
- @pytest .mark .slow
189
187
def test_plot_xy (self ):
190
188
# columns.inferred_type == 'string'
191
189
df = self .tdf
@@ -210,7 +208,6 @@ def test_plot_xy(self):
210
208
# columns.inferred_type == 'mixed'
211
209
# TODO add MultiIndex test
212
210
213
- @pytest .mark .slow
214
211
@pytest .mark .parametrize (
215
212
"input_log, expected_log" , [(True , "log" ), ("sym" , "symlog" )]
216
213
)
@@ -239,7 +236,6 @@ def test_invalid_logscale(self, input_param):
239
236
with pytest .raises (ValueError , match = msg ):
240
237
df .plot (** {input_param : "sm" })
241
238
242
- @pytest .mark .slow
243
239
def test_xcompat (self ):
244
240
import pandas as pd
245
241
@@ -488,7 +484,6 @@ def test_area_sharey_dont_overwrite(self):
488
484
assert ax1 ._shared_y_axes .joined (ax1 , ax2 )
489
485
assert ax2 ._shared_y_axes .joined (ax1 , ax2 )
490
486
491
- @pytest .mark .slow
492
487
def test_bar_linewidth (self ):
493
488
df = DataFrame (np .random .randn (5 , 5 ))
494
489
@@ -509,7 +504,6 @@ def test_bar_linewidth(self):
509
504
for r in ax .patches :
510
505
assert r .get_linewidth () == 2
511
506
512
- @pytest .mark .slow
513
507
def test_bar_barwidth (self ):
514
508
df = DataFrame (np .random .randn (5 , 5 ))
515
509
@@ -547,7 +541,6 @@ def test_bar_barwidth(self):
547
541
for r in ax .patches :
548
542
assert r .get_height () == width
549
543
550
- @pytest .mark .slow
551
544
def test_bar_bottom_left (self ):
552
545
df = DataFrame (np .random .rand (5 , 5 ))
553
546
ax = df .plot .bar (stacked = False , bottom = 1 )
@@ -576,7 +569,6 @@ def test_bar_bottom_left(self):
576
569
result = [p .get_x () for p in ax .patches ]
577
570
assert result == [1 ] * 5
578
571
579
- @pytest .mark .slow
580
572
def test_bar_nan (self ):
581
573
df = DataFrame ({"A" : [10 , np .nan , 20 ], "B" : [5 , 10 , 20 ], "C" : [1 , 2 , 3 ]})
582
574
ax = df .plot .bar ()
@@ -592,7 +584,6 @@ def test_bar_nan(self):
592
584
expected = [0.0 , 0.0 , 0.0 , 10.0 , 0.0 , 20.0 , 15.0 , 10.0 , 40.0 ]
593
585
assert result == expected
594
586
595
- @pytest .mark .slow
596
587
def test_bar_categorical (self ):
597
588
# GH 13019
598
589
df1 = DataFrame (
@@ -622,7 +613,6 @@ def test_bar_categorical(self):
622
613
assert ax .patches [0 ].get_x () == - 0.25
623
614
assert ax .patches [- 1 ].get_x () == 4.75
624
615
625
- @pytest .mark .slow
626
616
def test_plot_scatter (self ):
627
617
df = DataFrame (
628
618
np .random .randn (6 , 4 ),
@@ -673,14 +663,12 @@ def test_scatterplot_object_data(self):
673
663
_check_plot_works (df .plot .scatter , x = 0 , y = 1 )
674
664
675
665
@pytest .mark .parametrize ("x, y" , [("x" , "y" ), ("y" , "x" ), ("y" , "y" )])
676
- @pytest .mark .slow
677
666
def test_plot_scatter_with_categorical_data (self , x , y ):
678
667
# after fixing GH 18755, should be able to plot categorical data
679
668
df = DataFrame ({"x" : [1 , 2 , 3 , 4 ], "y" : pd .Categorical (["a" , "b" , "a" , "c" ])})
680
669
681
670
_check_plot_works (df .plot .scatter , x = x , y = y )
682
671
683
- @pytest .mark .slow
684
672
def test_plot_scatter_with_c (self ):
685
673
df = DataFrame (
686
674
np .random .randn (6 , 4 ),
@@ -739,7 +727,6 @@ def test_plot_scatter_with_s(self):
739
727
ax = df .plot .scatter (x = "a" , y = "b" , s = "c" )
740
728
tm .assert_numpy_array_equal (df ["c" ].values , right = ax .collections [0 ].get_sizes ())
741
729
742
- @pytest .mark .slow
743
730
def test_plot_bar (self ):
744
731
df = DataFrame (
745
732
np .random .randn (6 , 4 ),
@@ -772,7 +759,6 @@ def test_plot_bar(self):
772
759
ax = df .plot .barh (rot = 55 , fontsize = 11 )
773
760
self ._check_ticks_props (ax , yrot = 55 , ylabelsize = 11 , xlabelsize = 11 )
774
761
775
- @pytest .mark .slow
776
762
def test_boxplot (self ):
777
763
df = self .hist_df
778
764
series = df ["height" ]
@@ -801,7 +787,6 @@ def test_boxplot(self):
801
787
tm .assert_numpy_array_equal (ax .xaxis .get_ticklocs (), positions )
802
788
assert len (ax .lines ) == self .bp_n_objects * len (numeric_cols )
803
789
804
- @pytest .mark .slow
805
790
def test_boxplot_vertical (self ):
806
791
df = self .hist_df
807
792
numeric_cols = df ._get_numeric_data ().columns
@@ -832,7 +817,6 @@ def test_boxplot_vertical(self):
832
817
tm .assert_numpy_array_equal (ax .yaxis .get_ticklocs (), positions )
833
818
assert len (ax .lines ) == self .bp_n_objects * len (numeric_cols )
834
819
835
- @pytest .mark .slow
836
820
def test_boxplot_return_type (self ):
837
821
df = DataFrame (
838
822
np .random .randn (6 , 4 ),
@@ -854,7 +838,6 @@ def test_boxplot_return_type(self):
854
838
result = df .plot .box (return_type = "both" )
855
839
self ._check_box_return_type (result , "both" )
856
840
857
- @pytest .mark .slow
858
841
@td .skip_if_no_scipy
859
842
def test_kde_df (self ):
860
843
df = DataFrame (np .random .randn (100 , 4 ))
@@ -877,14 +860,12 @@ def test_kde_df(self):
877
860
axes = df .plot (kind = "kde" , logy = True , subplots = True )
878
861
self ._check_ax_scales (axes , yaxis = "log" )
879
862
880
- @pytest .mark .slow
881
863
@td .skip_if_no_scipy
882
864
def test_kde_missing_vals (self ):
883
865
df = DataFrame (np .random .uniform (size = (100 , 4 )))
884
866
df .loc [0 , 0 ] = np .nan
885
867
_check_plot_works (df .plot , kind = "kde" )
886
868
887
- @pytest .mark .slow
888
869
def test_hist_df (self ):
889
870
from matplotlib .patches import Rectangle
890
871
@@ -966,7 +947,6 @@ def _check_box_coord(
966
947
if expected_w is not None :
967
948
tm .assert_numpy_array_equal (result_width , expected_w , check_dtype = False )
968
949
969
- @pytest .mark .slow
970
950
def test_hist_df_coord (self ):
971
951
normal_df = DataFrame (
972
952
{
@@ -1098,12 +1078,10 @@ def test_hist_df_coord(self):
1098
1078
expected_w = np .array ([6 , 7 , 8 , 9 , 10 ]),
1099
1079
)
1100
1080
1101
- @pytest .mark .slow
1102
1081
def test_plot_int_columns (self ):
1103
1082
df = DataFrame (np .random .randn (100 , 4 )).cumsum ()
1104
1083
_check_plot_works (df .plot , legend = True )
1105
1084
1106
- @pytest .mark .slow
1107
1085
def test_df_legend_labels (self ):
1108
1086
kinds = ["line" , "bar" , "barh" , "kde" , "area" , "hist" ]
1109
1087
df = DataFrame (np .random .rand (3 , 3 ), columns = ["a" , "b" , "c" ])
@@ -1217,7 +1195,6 @@ def test_legend_name(self):
1217
1195
leg_title = ax .legend_ .get_title ()
1218
1196
self ._check_text_labels (leg_title , "new" )
1219
1197
1220
- @pytest .mark .slow
1221
1198
def test_no_legend (self ):
1222
1199
kinds = ["line" , "bar" , "barh" , "kde" , "area" , "hist" ]
1223
1200
df = DataFrame (np .random .rand (3 , 3 ), columns = ["a" , "b" , "c" ])
@@ -1226,7 +1203,6 @@ def test_no_legend(self):
1226
1203
ax = df .plot (kind = kind , legend = False )
1227
1204
self ._check_legend_labels (ax , visible = False )
1228
1205
1229
- @pytest .mark .slow
1230
1206
def test_style_by_column (self ):
1231
1207
import matplotlib .pyplot as plt
1232
1208
@@ -1245,7 +1221,6 @@ def test_style_by_column(self):
1245
1221
for idx , line in enumerate (ax .get_lines ()[: len (markers )]):
1246
1222
assert line .get_marker () == markers [idx ]
1247
1223
1248
- @pytest .mark .slow
1249
1224
def test_line_label_none (self ):
1250
1225
s = Series ([1 , 2 ])
1251
1226
ax = s .plot ()
@@ -1302,7 +1277,6 @@ def test_all_invalid_plot_data(self):
1302
1277
with pytest .raises (TypeError , match = msg ):
1303
1278
df .plot (kind = kind )
1304
1279
1305
- @pytest .mark .slow
1306
1280
def test_partially_invalid_plot_data (self ):
1307
1281
with tm .RNGContext (42 ):
1308
1282
df = DataFrame (np .random .randn (10 , 2 ), dtype = object )
@@ -1372,7 +1346,6 @@ def test_xy_args_integer(self, x, y, colnames):
1372
1346
df .columns = colnames
1373
1347
_check_plot_works (df .plot , x = x , y = y )
1374
1348
1375
- @pytest .mark .slow
1376
1349
def test_hexbin_basic (self ):
1377
1350
df = self .hexbin_df
1378
1351
@@ -1388,7 +1361,6 @@ def test_hexbin_basic(self):
1388
1361
# return value is single axes
1389
1362
self ._check_axes_shape (axes , axes_num = 1 , layout = (1 , 1 ))
1390
1363
1391
- @pytest .mark .slow
1392
1364
def test_hexbin_with_c (self ):
1393
1365
df = self .hexbin_df
1394
1366
@@ -1398,7 +1370,6 @@ def test_hexbin_with_c(self):
1398
1370
ax = df .plot .hexbin (x = "A" , y = "B" , C = "C" , reduce_C_function = np .std )
1399
1371
assert len (ax .collections ) == 1
1400
1372
1401
- @pytest .mark .slow
1402
1373
@pytest .mark .parametrize (
1403
1374
"kwargs, expected" ,
1404
1375
[
@@ -1412,7 +1383,6 @@ def test_hexbin_cmap(self, kwargs, expected):
1412
1383
ax = df .plot .hexbin (x = "A" , y = "B" , ** kwargs )
1413
1384
assert ax .collections [0 ].cmap .name == expected
1414
1385
1415
- @pytest .mark .slow
1416
1386
def test_pie_df (self ):
1417
1387
df = DataFrame (
1418
1388
np .random .rand (5 , 3 ),
@@ -1484,7 +1454,6 @@ def test_pie_df_nan(self):
1484
1454
expected_labels = base_expected [:i ] + base_expected [i + 1 :]
1485
1455
assert result_labels == expected_labels
1486
1456
1487
- @pytest .mark .slow
1488
1457
def test_errorbar_plot (self ):
1489
1458
d = {"x" : np .arange (12 ), "y" : np .arange (12 , 0 , - 1 )}
1490
1459
df = DataFrame (d )
@@ -1531,7 +1500,6 @@ def test_errorbar_plot(self):
1531
1500
with pytest .raises ((ValueError , TypeError )):
1532
1501
df .plot (yerr = df_err )
1533
1502
1534
- @pytest .mark .slow
1535
1503
@pytest .mark .parametrize ("kind" , ["line" , "bar" , "barh" ])
1536
1504
def test_errorbar_plot_different_kinds (self , kind ):
1537
1505
d = {"x" : np .arange (12 ), "y" : np .arange (12 , 0 , - 1 )}
@@ -1565,7 +1533,6 @@ def test_errorbar_plot_different_kinds(self, kind):
1565
1533
self ._check_has_errorbars (axes , xerr = 1 , yerr = 1 )
1566
1534
1567
1535
@pytest .mark .xfail (reason = "Iterator is consumed" , raises = ValueError )
1568
- @pytest .mark .slow
1569
1536
def test_errorbar_plot_iterator (self ):
1570
1537
with warnings .catch_warnings ():
1571
1538
d = {"x" : np .arange (12 ), "y" : np .arange (12 , 0 , - 1 )}
@@ -1575,7 +1542,6 @@ def test_errorbar_plot_iterator(self):
1575
1542
ax = _check_plot_works (df .plot , yerr = itertools .repeat (0.1 , len (df )))
1576
1543
self ._check_has_errorbars (ax , xerr = 0 , yerr = 2 )
1577
1544
1578
- @pytest .mark .slow
1579
1545
def test_errorbar_with_integer_column_names (self ):
1580
1546
# test with integer column names
1581
1547
df = DataFrame (np .random .randn (10 , 2 ))
@@ -1585,7 +1551,6 @@ def test_errorbar_with_integer_column_names(self):
1585
1551
ax = _check_plot_works (df .plot , y = 0 , yerr = 1 )
1586
1552
self ._check_has_errorbars (ax , xerr = 0 , yerr = 1 )
1587
1553
1588
- @pytest .mark .slow
1589
1554
def test_errorbar_with_partial_columns (self ):
1590
1555
df = DataFrame (np .random .randn (10 , 3 ))
1591
1556
df_err = DataFrame (np .random .randn (10 , 2 ), columns = [0 , 2 ])
@@ -1608,7 +1573,6 @@ def test_errorbar_with_partial_columns(self):
1608
1573
ax = _check_plot_works (df .plot , yerr = err )
1609
1574
self ._check_has_errorbars (ax , xerr = 0 , yerr = 1 )
1610
1575
1611
- @pytest .mark .slow
1612
1576
@pytest .mark .parametrize ("kind" , ["line" , "bar" , "barh" ])
1613
1577
def test_errorbar_timeseries (self , kind ):
1614
1578
d = {"x" : np .arange (12 ), "y" : np .arange (12 , 0 , - 1 )}
@@ -1713,7 +1677,6 @@ def _check_errorbar_color(containers, expected, has_err="has_xerr"):
1713
1677
self ._check_has_errorbars (ax , xerr = 0 , yerr = 1 )
1714
1678
_check_errorbar_color (ax .containers , "green" , has_err = "has_yerr" )
1715
1679
1716
- @pytest .mark .slow
1717
1680
def test_sharex_and_ax (self ):
1718
1681
# https://github.com/pandas-dev/pandas/issues/9737 using gridspec,
1719
1682
# the axis in fig.get_axis() are sorted differently than pandas
@@ -1768,7 +1731,6 @@ def _check(axes):
1768
1731
self ._check_visible (ax .get_xticklabels (minor = True ), visible = True )
1769
1732
tm .close ()
1770
1733
1771
- @pytest .mark .slow
1772
1734
def test_sharey_and_ax (self ):
1773
1735
# https://github.com/pandas-dev/pandas/issues/9737 using gridspec,
1774
1736
# the axis in fig.get_axis() are sorted differently than pandas
@@ -1854,7 +1816,6 @@ def test_memory_leak(self):
1854
1816
# need to actually access something to get an error
1855
1817
results [key ].lines
1856
1818
1857
- @pytest .mark .slow
1858
1819
def test_df_gridspec_patterns (self ):
1859
1820
# GH 10819
1860
1821
import matplotlib .gridspec as gridspec
@@ -1970,7 +1931,6 @@ def _get_boxed_grid():
1970
1931
self ._check_visible (ax .get_xticklabels (minor = True ), visible = True )
1971
1932
tm .close ()
1972
1933
1973
- @pytest .mark .slow
1974
1934
def test_df_grid_settings (self ):
1975
1935
# Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
1976
1936
self ._check_grid_settings (
@@ -2026,7 +1986,6 @@ def test_secondary_axis_font_size(self, method):
2026
1986
ax = getattr (df .plot , method )(** kwargs )
2027
1987
self ._check_ticks_props (axes = ax .right_ax , ylabelsize = fontsize )
2028
1988
2029
- @pytest .mark .slow
2030
1989
def test_x_string_values_ticks (self ):
2031
1990
# Test if string plot index have a fixed xtick position
2032
1991
# GH: 7612, GH: 22334
@@ -2046,7 +2005,6 @@ def test_x_string_values_ticks(self):
2046
2005
assert labels_position ["Tuesday" ] == 1.0
2047
2006
assert labels_position ["Wednesday" ] == 2.0
2048
2007
2049
- @pytest .mark .slow
2050
2008
def test_x_multiindex_values_ticks (self ):
2051
2009
# Test if multiindex plot index have a fixed xtick position
2052
2010
# GH: 15912
@@ -2190,7 +2148,6 @@ def test_xlabel_ylabel_dataframe_plane_plot(self, kind, xlabel, ylabel):
2190
2148
assert ax .get_xlabel () == (xcol if xlabel is None else xlabel )
2191
2149
assert ax .get_ylabel () == (ycol if ylabel is None else ylabel )
2192
2150
2193
- @pytest .mark .slow
2194
2151
@pytest .mark .parametrize ("method" , ["bar" , "barh" ])
2195
2152
def test_bar_ticklabel_consistence (self , method ):
2196
2153
# Draw two consecutiv bar plot with consistent ticklabels
0 commit comments