6
6
import flox .aggregations
7
7
8
8
N = 3000
9
- funcs = ["sum" , "nansum" , "mean" , "nanmean" , "max" , "nanmax" , "var" , " count" , "all " ]
9
+ funcs = ["sum" , "nansum" , "mean" , "nanmean" , "max" , "nanmax" , "count" ]
10
10
engines = ["flox" , "numpy" , "numbagg" ]
11
11
expected_groups = {
12
12
"None" : None ,
13
- "RangeIndex" : pd .RangeIndex (5 ),
14
13
"bins" : pd .IntervalIndex .from_breaks ([1 , 2 , 4 ]),
15
14
}
16
15
expected_names = tuple (expected_groups )
17
16
18
17
NUMBAGG_FUNCS = ["nansum" , "nanmean" , "nanmax" , "count" , "all" ]
19
-
20
- numbagg_skip = [
21
- (func , expected_names [0 ], "numbagg" ) for func in funcs if func not in NUMBAGG_FUNCS
22
- ] + [(func , expected_names [1 ], "numbagg" ) for func in funcs if func not in NUMBAGG_FUNCS ]
18
+ numbagg_skip = []
19
+ for name in expected_names :
20
+ numbagg_skip .extend (
21
+ list ((func , expected_names [0 ], "numbagg" ) for func in funcs if func not in NUMBAGG_FUNCS )
22
+ )
23
23
24
24
25
25
def setup_jit ():
@@ -42,7 +42,7 @@ class ChunkReduce:
42
42
"""Time the core reduction function."""
43
43
44
44
min_run_count = 5
45
- warmup_time = 1
45
+ warmup_time = 0.5
46
46
47
47
def setup (self , * args , ** kwargs ):
48
48
raise NotImplementedError
@@ -59,18 +59,6 @@ def time_reduce(self, func, expected_name, engine):
59
59
expected_groups = expected_groups [expected_name ],
60
60
)
61
61
62
- @parameterize ({"func" : ["nansum" , "nanmean" , "nanmax" , "count" ], "engine" : engines })
63
- def time_reduce_bare (self , func , engine ):
64
- flox .aggregations .generic_aggregate (
65
- self .labels ,
66
- self .array ,
67
- axis = - 1 ,
68
- size = 5 ,
69
- func = func ,
70
- engine = engine ,
71
- fill_value = 0 ,
72
- )
73
-
74
62
@skip_for_params (numbagg_skip )
75
63
@parameterize ({"func" : funcs , "expected_name" : expected_names , "engine" : engines })
76
64
def peakmem_reduce (self , func , expected_name , engine ):
@@ -92,13 +80,18 @@ def setup(self, *args, **kwargs):
92
80
if "numbagg" in args :
93
81
setup_jit ()
94
82
95
-
96
- class ChunkReduce1DUnsorted (ChunkReduce ):
97
- def setup (self , * args , ** kwargs ):
98
- self .array = np .ones ((N ,))
99
- self .labels = np .random .permutation (np .repeat (np .arange (5 ), repeats = N // 5 ))
100
- self .axis = - 1
101
- setup_jit ()
83
+ @parameterize ({"func" : ["nansum" , "nanmean" , "nanmax" , "count" ], "engine" : engines })
84
+ def time_reduce_bare (self , func , engine ):
85
+ # TODO: migrate to the other test cases, but we'll have to setup labels
86
+ # appropriately ;(
87
+ flox .aggregations .generic_aggregate (
88
+ self .labels ,
89
+ self .array ,
90
+ axis = self .axis ,
91
+ func = func ,
92
+ engine = engine ,
93
+ fill_value = 0 ,
94
+ )
102
95
103
96
104
97
class ChunkReduce2D (ChunkReduce ):
@@ -109,14 +102,6 @@ def setup(self, *args, **kwargs):
109
102
setup_jit ()
110
103
111
104
112
- class ChunkReduce2DUnsorted (ChunkReduce ):
113
- def setup (self , * args , ** kwargs ):
114
- self .array = np .ones ((N , N ))
115
- self .labels = np .random .permutation (np .repeat (np .arange (N // 5 ), repeats = 5 ))
116
- self .axis = - 1
117
- setup_jit ()
118
-
119
-
120
105
class ChunkReduce2DAllAxes (ChunkReduce ):
121
106
def setup (self , * args , ** kwargs ):
122
107
self .array = np .ones ((N , N ))
@@ -125,9 +110,24 @@ def setup(self, *args, **kwargs):
125
110
setup_jit ()
126
111
127
112
128
- class ChunkReduce2DAllAxesUnsorted (ChunkReduce ):
129
- def setup (self , * args , ** kwargs ):
130
- self .array = np .ones ((N , N ))
131
- self .labels = np .random .permutation (np .repeat (np .arange (N // 5 ), repeats = 5 ))
132
- self .axis = None
133
- setup_jit ()
113
+ # class ChunkReduce2DUnsorted(ChunkReduce):
114
+ # def setup(self, *args, **kwargs):
115
+ # self.array = np.ones((N, N))
116
+ # self.labels = np.random.permutation(np.repeat(np.arange(N // 5), repeats=5))
117
+ # self.axis = -1
118
+ # setup_jit()
119
+
120
+ # class ChunkReduce1DUnsorted(ChunkReduce):
121
+ # def setup(self, *args, **kwargs):
122
+ # self.array = np.ones((N,))
123
+ # self.labels = np.random.permutation(np.repeat(np.arange(5), repeats=N // 5))
124
+ # self.axis = -1
125
+ # setup_jit()
126
+
127
+
128
+ # class ChunkReduce2DAllAxesUnsorted(ChunkReduce):
129
+ # def setup(self, *args, **kwargs):
130
+ # self.array = np.ones((N, N))
131
+ # self.labels = np.random.permutation(np.repeat(np.arange(N // 5), repeats=5))
132
+ # self.axis = None
133
+ # setup_jit()
0 commit comments