@@ -777,8 +777,8 @@ def get_result(obj, window, min_periods=None, center=False):
777777 series_result = get_result (series , window = win , min_periods = minp )
778778 frame_result = get_result (frame , window = win , min_periods = minp )
779779 else :
780- series_result = get_result (series , window = win )
781- frame_result = get_result (frame , window = win )
780+ series_result = get_result (series , window = win , min_periods = 0 )
781+ frame_result = get_result (frame , window = win , min_periods = 0 )
782782
783783 last_date = series_result .index [- 1 ]
784784 prev_date = last_date - 24 * offsets .BDay ()
@@ -835,8 +835,8 @@ def get_result(obj, window, min_periods=None, center=False):
835835 nan_mask = ~ nan_mask
836836 tm .assert_almost_equal (result [nan_mask ], expected [nan_mask ])
837837 else :
838- result = get_result (self .series , len (self .series ) + 1 )
839- expected = get_result (self .series , len (self .series ))
838+ result = get_result (self .series , len (self .series ) + 1 , min_periods = 0 )
839+ expected = get_result (self .series , len (self .series ), min_periods = 0 )
840840 nan_mask = isna (result )
841841 tm .assert_series_equal (nan_mask , isna (expected ))
842842
@@ -851,10 +851,11 @@ def get_result(obj, window, min_periods=None, center=False):
851851 pd .concat ([obj , Series ([np .NaN ] * 9 )]), 20 , min_periods = 15
852852 )[9 :].reset_index (drop = True )
853853 else :
854- result = get_result (obj , 20 , center = True )
855- expected = get_result (pd .concat ([obj , Series ([np .NaN ] * 9 )]), 20 )[
856- 9 :
857- ].reset_index (drop = True )
854+ result = get_result (obj , 20 , min_periods = 0 , center = True )
855+ print (result )
856+ expected = get_result (
857+ pd .concat ([obj , Series ([np .NaN ] * 9 )]), 20 , min_periods = 0
858+ )[9 :].reset_index (drop = True )
858859
859860 tm .assert_series_equal (result , expected )
860861
@@ -893,21 +894,27 @@ def get_result(obj, window, min_periods=None, center=False):
893894 else :
894895 series_xp = (
895896 get_result (
896- self .series .reindex (list (self .series .index ) + s ), window = 25
897+ self .series .reindex (list (self .series .index ) + s ),
898+ window = 25 ,
899+ min_periods = 0 ,
897900 )
898901 .shift (- 12 )
899902 .reindex (self .series .index )
900903 )
901904 frame_xp = (
902905 get_result (
903- self .frame .reindex (list (self .frame .index ) + s ), window = 25
906+ self .frame .reindex (list (self .frame .index ) + s ),
907+ window = 25 ,
908+ min_periods = 0 ,
904909 )
905910 .shift (- 12 )
906911 .reindex (self .frame .index )
907912 )
908913
909- series_rs = get_result (self .series , window = 25 , center = True )
910- frame_rs = get_result (self .frame , window = 25 , center = True )
914+ series_rs = get_result (
915+ self .series , window = 25 , min_periods = 0 , center = True
916+ )
917+ frame_rs = get_result (self .frame , window = 25 , min_periods = 0 , center = True )
911918
912919 if fill_value is not None :
913920 series_xp = series_xp .fillna (fill_value )
@@ -964,7 +971,11 @@ def test_rolling_consistency(self, window, min_periods, center):
964971
965972 self ._test_moments_consistency_is_constant (
966973 min_periods = min_periods ,
967- count = lambda x : (x .rolling (window = window , center = center ).count ()),
974+ count = lambda x : (
975+ x .rolling (
976+ window = window , min_periods = min_periods , center = center
977+ ).count ()
978+ ),
968979 mean = lambda x : (
969980 x .rolling (
970981 window = window , min_periods = min_periods , center = center
@@ -989,19 +1000,26 @@ def test_rolling_consistency(self, window, min_periods, center):
9891000 ).var (ddof = 0 )
9901001 ),
9911002 var_debiasing_factors = lambda x : (
992- x .rolling (window = window , center = center )
1003+ x .rolling (window = window , min_periods = min_periods , center = center )
9931004 .count ()
9941005 .divide (
995- (x .rolling (window = window , center = center ).count () - 1.0 ).replace (
996- 0.0 , np .nan
997- )
1006+ (
1007+ x .rolling (
1008+ window = window , min_periods = min_periods , center = center
1009+ ).count ()
1010+ - 1.0
1011+ ).replace (0.0 , np .nan )
9981012 )
9991013 ),
10001014 )
10011015
10021016 self ._test_moments_consistency (
10031017 min_periods = min_periods ,
1004- count = lambda x : (x .rolling (window = window , center = center ).count ()),
1018+ count = lambda x : (
1019+ x .rolling (
1020+ window = window , min_periods = min_periods , center = center
1021+ ).count ()
1022+ ),
10051023 mean = lambda x : (
10061024 x .rolling (
10071025 window = window , min_periods = min_periods , center = center
@@ -1071,7 +1089,7 @@ def test_rolling_consistency(self, window, min_periods, center):
10711089 if name == "count" :
10721090 rolling_f_result = rolling_f ()
10731091 rolling_apply_f_result = x .rolling (
1074- window = window , min_periods = 0 , center = center
1092+ window = window , min_periods = min_periods , center = center
10751093 ).apply (func = f , raw = True )
10761094 else :
10771095 if name in ["cov" , "corr" ]:
0 commit comments