-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
/
Copy pathconftest.py
166 lines (145 loc) · 3.8 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
Series,
date_range,
)
from pandas.core.groupby.base import (
reduction_kernels,
transformation_kernels,
)
@pytest.fixture
def df():
return DataFrame(
{
"A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
"B": ["one", "one", "two", "three", "two", "two", "one", "three"],
"C": np.random.default_rng(2).standard_normal(8),
"D": np.random.default_rng(2).standard_normal(8),
}
)
@pytest.fixture
def ts():
return Series(
np.random.default_rng(2).standard_normal(30),
index=date_range("2000-01-01", periods=30, freq="B"),
)
@pytest.fixture
def tsframe():
return DataFrame(
np.random.default_rng(2).standard_normal((30, 4)),
columns=Index(list("ABCD"), dtype=object),
index=date_range("2000-01-01", periods=30, freq="B"),
)
@pytest.fixture
def three_group():
return DataFrame(
{
"A": [
"foo",
"foo",
"foo",
"foo",
"bar",
"bar",
"bar",
"bar",
"foo",
"foo",
"foo",
],
"B": [
"one",
"one",
"one",
"two",
"one",
"one",
"one",
"two",
"two",
"two",
"one",
],
"C": [
"dull",
"dull",
"shiny",
"dull",
"dull",
"shiny",
"shiny",
"dull",
"shiny",
"shiny",
"shiny",
],
"D": np.random.default_rng(2).standard_normal(11),
"E": np.random.default_rng(2).standard_normal(11),
"F": np.random.default_rng(2).standard_normal(11),
}
)
@pytest.fixture
def slice_test_df():
data = [
[0, "a", "a0_at_0"],
[1, "b", "b0_at_1"],
[2, "a", "a1_at_2"],
[3, "b", "b1_at_3"],
[4, "c", "c0_at_4"],
[5, "a", "a2_at_5"],
[6, "a", "a3_at_6"],
[7, "a", "a4_at_7"],
]
df = DataFrame(data, columns=["Index", "Group", "Value"])
return df.set_index("Index")
@pytest.fixture
def slice_test_grouped(slice_test_df):
return slice_test_df.groupby("Group", as_index=False)
@pytest.fixture(params=sorted(reduction_kernels))
def reduction_func(request):
"""
yields the string names of all groupby reduction functions, one at a time.
"""
return request.param
@pytest.fixture(params=sorted(transformation_kernels))
def transformation_func(request):
"""yields the string names of all groupby transformation functions."""
return request.param
@pytest.fixture(params=sorted(reduction_kernels) + sorted(transformation_kernels))
def groupby_func(request):
"""yields both aggregation and transformation functions."""
return request.param
@pytest.fixture(
params=[
("mean", {}),
("var", {"ddof": 1}),
("var", {"ddof": 0}),
("std", {"ddof": 1}),
("std", {"ddof": 0}),
("sum", {}),
("min", {}),
("max", {}),
("sum", {"min_count": 2}),
("min", {"min_count": 2}),
("max", {"min_count": 2}),
],
ids=[
"mean",
"var_1",
"var_0",
"std_1",
"std_0",
"sum",
"min",
"max",
"sum-min_count",
"min-min_count",
"max-min_count",
],
)
def numba_supported_reductions(request):
"""reductions supported with engine='numba'"""
return request.param