@@ -94,7 +94,6 @@ def get_window_bounds(self, num_values, min_periods, center, closed, step):
94
94
tm .assert_frame_equal (result , expected )
95
95
96
96
97
- @pytest .mark .parametrize ("constructor" , [Series , DataFrame ])
98
97
@pytest .mark .parametrize (
99
98
"func,np_func,expected,np_kwargs" ,
100
99
[
@@ -149,7 +148,9 @@ def get_window_bounds(self, num_values, min_periods, center, closed, step):
149
148
],
150
149
)
151
150
@pytest .mark .filterwarnings ("ignore:min_periods:FutureWarning" )
152
- def test_rolling_forward_window (constructor , func , np_func , expected , np_kwargs , step ):
151
+ def test_rolling_forward_window (
152
+ frame_or_series , func , np_func , expected , np_kwargs , step
153
+ ):
153
154
# GH 32865
154
155
values = np .arange (10.0 )
155
156
values [5 ] = 100.0
@@ -158,47 +159,46 @@ def test_rolling_forward_window(constructor, func, np_func, expected, np_kwargs,
158
159
159
160
match = "Forward-looking windows can't have center=True"
160
161
with pytest .raises (ValueError , match = match ):
161
- rolling = constructor (values ).rolling (window = indexer , center = True )
162
+ rolling = frame_or_series (values ).rolling (window = indexer , center = True )
162
163
getattr (rolling , func )()
163
164
164
165
match = "Forward-looking windows don't support setting the closed argument"
165
166
with pytest .raises (ValueError , match = match ):
166
- rolling = constructor (values ).rolling (window = indexer , closed = "right" )
167
+ rolling = frame_or_series (values ).rolling (window = indexer , closed = "right" )
167
168
getattr (rolling , func )()
168
169
169
- rolling = constructor (values ).rolling (window = indexer , min_periods = 2 , step = step )
170
+ rolling = frame_or_series (values ).rolling (window = indexer , min_periods = 2 , step = step )
170
171
result = getattr (rolling , func )()
171
172
172
173
# Check that the function output matches the explicitly provided array
173
- expected = constructor (expected )[::step ]
174
+ expected = frame_or_series (expected )[::step ]
174
175
tm .assert_equal (result , expected )
175
176
176
177
# Check that the rolling function output matches applying an alternative
177
178
# function to the rolling window object
178
- expected2 = constructor (rolling .apply (lambda x : np_func (x , ** np_kwargs )))
179
+ expected2 = frame_or_series (rolling .apply (lambda x : np_func (x , ** np_kwargs )))
179
180
tm .assert_equal (result , expected2 )
180
181
181
182
# Check that the function output matches applying an alternative function
182
183
# if min_periods isn't specified
183
184
# GH 39604: After count-min_periods deprecation, apply(lambda x: len(x))
184
185
# is equivalent to count after setting min_periods=0
185
186
min_periods = 0 if func == "count" else None
186
- rolling3 = constructor (values ).rolling (window = indexer , min_periods = min_periods )
187
+ rolling3 = frame_or_series (values ).rolling (window = indexer , min_periods = min_periods )
187
188
result3 = getattr (rolling3 , func )()
188
- expected3 = constructor (rolling3 .apply (lambda x : np_func (x , ** np_kwargs )))
189
+ expected3 = frame_or_series (rolling3 .apply (lambda x : np_func (x , ** np_kwargs )))
189
190
tm .assert_equal (result3 , expected3 )
190
191
191
192
192
- @pytest .mark .parametrize ("constructor" , [Series , DataFrame ])
193
- def test_rolling_forward_skewness (constructor , step ):
193
+ def test_rolling_forward_skewness (frame_or_series , step ):
194
194
values = np .arange (10.0 )
195
195
values [5 ] = 100.0
196
196
197
197
indexer = FixedForwardWindowIndexer (window_size = 5 )
198
- rolling = constructor (values ).rolling (window = indexer , min_periods = 3 , step = step )
198
+ rolling = frame_or_series (values ).rolling (window = indexer , min_periods = 3 , step = step )
199
199
result = rolling .skew ()
200
200
201
- expected = constructor (
201
+ expected = frame_or_series (
202
202
[
203
203
0.0 ,
204
204
2.232396 ,
0 commit comments