2
2
import nose
3
3
import unittest
4
4
5
+ from numpy .testing .decorators import slow
6
+
5
7
from datetime import datetime
6
8
from numpy import nan
7
9
8
10
from pandas import bdate_range
9
11
from pandas .core .index import Index , MultiIndex
10
12
from pandas .core .common import rands
11
13
from pandas .core .api import Categorical , DataFrame
12
- from pandas .core .groupby import (GroupByError , SpecificationError , DataError ,
13
- _apply_whitelist )
14
+ from pandas .core .groupby import SpecificationError , DataError
14
15
from pandas .core .series import Series
15
16
from pandas .util .testing import (assert_panel_equal , assert_frame_equal ,
16
17
assert_series_equal , assert_almost_equal ,
17
18
assert_index_equal )
18
19
from pandas .compat import (
19
20
range , long , lrange , StringIO , lmap , lzip , map , zip , builtins , OrderedDict
20
21
)
21
- from pandas import compat , _np_version_under1p7
22
+ from pandas import compat
22
23
from pandas .core .panel import Panel
23
24
from pandas .tools .merge import concat
24
25
from collections import defaultdict
25
26
import pandas .core .common as com
26
- import pandas .core .datetools as dt
27
27
import numpy as np
28
- from numpy .testing import assert_equal
29
28
30
29
import pandas .core .nanops as nanops
31
30
@@ -2730,7 +2729,8 @@ def test_groupby_whitelist(self):
2730
2729
2731
2730
def test_series_groupby_plotting_nominally_works (self ):
2732
2731
try :
2733
- import matplotlib .pyplot as plt
2732
+ import matplotlib as mpl
2733
+ mpl .use ('Agg' )
2734
2734
except ImportError :
2735
2735
raise nose .SkipTest ("matplotlib not installed" )
2736
2736
n = 10
@@ -2743,9 +2743,12 @@ def test_series_groupby_plotting_nominally_works(self):
2743
2743
height .groupby (gender ).hist ()
2744
2744
tm .close ()
2745
2745
2746
+ @slow
2746
2747
def test_frame_groupby_plot_boxplot (self ):
2747
2748
try :
2748
2749
import matplotlib .pyplot as plt
2750
+ import matplotlib as mpl
2751
+ mpl .use ('Agg' )
2749
2752
except ImportError :
2750
2753
raise nose .SkipTest ("matplotlib not installed" )
2751
2754
tm .close ()
@@ -2767,12 +2770,15 @@ def test_frame_groupby_plot_boxplot(self):
2767
2770
self .assertEqual (len (res ), 2 )
2768
2771
tm .close ()
2769
2772
2770
- with tm .assertRaises (TypeError , '.*str.+float' ):
2773
+ with tm .assertRaisesRegexp (TypeError , '.*str.+float' ):
2771
2774
gb .hist ()
2772
2775
2776
+ @slow
2773
2777
def test_frame_groupby_hist (self ):
2774
2778
try :
2775
2779
import matplotlib .pyplot as plt
2780
+ import matplotlib as mpl
2781
+ mpl .use ('Agg' )
2776
2782
except ImportError :
2777
2783
raise nose .SkipTest ("matplotlib not installed" )
2778
2784
tm .close ()
@@ -2791,14 +2797,14 @@ def test_frame_groupby_hist(self):
2791
2797
2792
2798
def test_tab_completion (self ):
2793
2799
grp = self .mframe .groupby (level = 'second' )
2794
- results = set ([v for v in grp . __dir__ ( ) if not v .startswith ('_' )])
2800
+ results = set ([v for v in dir ( grp ) if not v .startswith ('_' )])
2795
2801
expected = set (['A' ,'B' ,'C' ,
2796
2802
'agg' ,'aggregate' ,'apply' ,'boxplot' ,'filter' ,'first' ,'get_group' ,
2797
2803
'groups' ,'hist' ,'indices' ,'last' ,'max' ,'mean' ,'median' ,
2798
2804
'min' ,'name' ,'ngroups' ,'nth' ,'ohlc' ,'plot' , 'prod' ,
2799
2805
'size' ,'std' ,'sum' ,'transform' ,'var' , 'count' , 'head' , 'describe' ,
2800
- 'cummax' , 'dtype' , 'quantile' , 'rank' ,
2801
- 'cumprod' , 'tail' , ' resample' , 'cummin' , 'fillna' , 'cumsum' ])
2806
+ 'cummax' , 'dtype' , 'quantile' , 'rank' , 'cumprod' , 'tail' ,
2807
+ 'resample' , 'cummin' , 'fillna' , 'cumsum' ])
2802
2808
self .assertEqual (results , expected )
2803
2809
2804
2810
def assert_fp_equal (a , b ):
@@ -2836,7 +2842,5 @@ def testit(label_list, shape):
2836
2842
2837
2843
2838
2844
if __name__ == '__main__' :
2839
- import nose
2840
- nose .runmodule (
2841
- argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' , '-s' ],
2842
- exit = False )
2845
+ nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ,
2846
+ '-s' ], exit = False )
0 commit comments