@@ -190,22 +190,28 @@ def test_fperr_robustness(self):
190
190
191
191
def _check_moment_func (self , func , static_comp , window = 50 ,
192
192
has_min_periods = True ,
193
+ has_center = True ,
193
194
has_time_rule = True ,
194
195
preserve_nan = True ,
195
196
fill_value = None ):
196
197
197
198
self ._check_ndarray (func , static_comp , window = window ,
198
199
has_min_periods = has_min_periods ,
199
- preserve_nan = preserve_nan )
200
+ preserve_nan = preserve_nan ,
201
+ has_center = has_center ,
202
+ fill_value = fill_value )
200
203
201
204
self ._check_structures (func , static_comp ,
202
205
has_min_periods = has_min_periods ,
203
206
has_time_rule = has_time_rule ,
204
- fill_value = fill_value )
207
+ fill_value = fill_value ,
208
+ has_center = has_center )
205
209
206
210
def _check_ndarray (self , func , static_comp , window = 50 ,
207
211
has_min_periods = True ,
208
- preserve_nan = True ):
212
+ preserve_nan = True ,
213
+ has_center = True ,
214
+ fill_value = None ):
209
215
210
216
result = func (self .arr , window )
211
217
assert_almost_equal (result [- 1 ],
@@ -244,6 +250,26 @@ def _check_ndarray(self, func, static_comp, window=50,
244
250
result = func (arr , 50 )
245
251
assert_almost_equal (result [- 1 ], static_comp (arr [10 :- 10 ]))
246
252
253
+
254
+ if has_center :
255
+ if has_min_periods :
256
+ result = func (arr , 20 , min_periods = 15 , center = True )
257
+ expected = func (arr , 20 , min_periods = 15 )
258
+ else :
259
+ result = func (arr , 20 , center = True )
260
+ expected = func (arr , 20 )
261
+
262
+ assert_almost_equal (result [0 ], expected [10 ])
263
+ if fill_value is None :
264
+ self .assert_ (np .isnan (result [- 10 :]).all ())
265
+ else :
266
+ self .assert_ ((result [- 10 :] == 0 ).all ())
267
+ if has_min_periods :
268
+ self .assert_ (np .isnan (expected [23 ]))
269
+ self .assert_ (np .isnan (result [13 ]))
270
+ self .assert_ (np .isnan (expected [- 5 ]))
271
+ self .assert_ (np .isnan (result [- 15 ]))
272
+
247
273
def _check_structures (self , func , static_comp ,
248
274
has_min_periods = True , has_time_rule = True ,
249
275
has_center = True ,
0 commit comments