1
- TIME = 0
2
- ENTITY = 1
3
-
4
1
def _get_cluster_type (cluster_type ):
5
- if cluster_type in (TIME , ENTITY , None ):
2
+ cluster_type = _WINDOW_TYPES .get (cluster_type , cluster_type )
3
+ if cluster_type is None :
6
4
return cluster_type
7
5
8
- elif isinstance (cluster_type , basestring ):
9
- cluster_type_up = cluster_type .upper ()
10
-
11
- if cluster_type_up == 'ENTITY' :
12
- return ENTITY
13
- elif cluster_type_up == 'TIME' :
14
- return TIME
6
+ cluster_type_up = cluster_type .upper ()
15
7
16
- raise Exception ('Unrecognized clustering type: %s' % cluster_type )
8
+ if cluster_type_up == 'ENTITY' :
9
+ return 'entity'
10
+ elif cluster_type_up == 'TIME' :
11
+ return 'time'
12
+ else : # pragma: no cover
13
+ raise Exception ('Unrecognized cluster type: %s' % cluster_type )
17
14
18
- FULL_SAMPLE = 0
19
- ROLLING = 1
20
- EXPANDING = 2
21
-
22
- def _get_window_type (window_type ):
23
- if window_type in (FULL_SAMPLE , ROLLING , EXPANDING ):
24
- return window_type
25
- elif isinstance (window_type , basestring ):
26
- window_type_up = window_type .upper ()
15
+ _CLUSTER_TYPES = {
16
+ 0 : 'time' ,
17
+ 1 : 'entity'
18
+ }
27
19
28
- if window_type_up in ('FULL SAMPLE' , 'FULL_SAMPLE' ):
29
- return FULL_SAMPLE
30
- elif window_type_up == 'ROLLING' :
31
- return ROLLING
32
- elif window_type_up == 'EXPANDING' :
33
- return EXPANDING
20
+ _WINDOW_TYPES = {
21
+ 0 : 'full_sample' ,
22
+ 1 : 'rolling' ,
23
+ 2 : 'expanding'
24
+ }
34
25
35
- raise Exception ('Unrecognized window type: %s' % window_type )
36
26
37
- def _get_window_type_name (window_type ):
38
- names = {
39
- 0 : 'full sample' ,
40
- 1 : 'rolling' ,
41
- 2 : 'expanding'
42
- }
43
- return names [window_type ]
27
+ def _get_window_type (window_type ):
28
+ window_type = _WINDOW_TYPES .get (window_type , window_type )
29
+ window_type_up = window_type .upper ()
30
+
31
+ if window_type_up in ('FULL SAMPLE' , 'FULL_SAMPLE' ):
32
+ return 'full_sample'
33
+ elif window_type_up == 'ROLLING' :
34
+ return 'rolling'
35
+ elif window_type_up == 'EXPANDING' :
36
+ return 'expanding'
37
+ else : # pragma: no cover
38
+ raise Exception ('Unrecognized window type: %s' % window_type )
44
39
45
40
def banner (text , width = 80 ):
46
41
"""
@@ -52,14 +47,3 @@ def banner(text, width=80):
52
47
right = toFill - left
53
48
54
49
return '%s%s%s' % ('-' * left , text , '-' * right )
55
-
56
- def f_stat_to_dict (result ):
57
- f_stat , shape , p_value = result
58
-
59
- result = {}
60
- result ['f-stat' ] = f_stat
61
- result ['DF X' ] = shape [0 ]
62
- result ['DF Resid' ] = shape [1 ]
63
- result ['p-value' ] = p_value
64
-
65
- return result
0 commit comments