1
- import copy
2
-
3
1
import numpy as np
4
2
from numpy .random import randn
5
3
import pytest
@@ -26,12 +24,6 @@ def _check_moment_func(
26
24
frame = None ,
27
25
** kwargs ,
28
26
):
29
-
30
- # inject raw
31
- if name == "apply" :
32
- kwargs = copy .copy (kwargs )
33
- kwargs ["raw" ] = raw
34
-
35
27
def get_result (obj , window , min_periods = None , center = False ):
36
28
r = obj .rolling (window = window , min_periods = min_periods , center = center )
37
29
return getattr (r , name )(** kwargs )
@@ -211,34 +203,6 @@ def test_centered_axis_validation():
211
203
(DataFrame (np .ones ((10 , 10 ))).rolling (window = 3 , center = True , axis = 2 ).mean ())
212
204
213
205
214
- def test_rolling_sum (raw , series , frame ):
215
- _check_moment_func (
216
- np .nansum ,
217
- name = "sum" ,
218
- zero_min_periods_equal = False ,
219
- raw = raw ,
220
- series = series ,
221
- frame = frame ,
222
- )
223
-
224
-
225
- def test_rolling_count (raw , series , frame ):
226
- counter = lambda x : np .isfinite (x ).astype (float ).sum ()
227
- _check_moment_func (
228
- counter ,
229
- name = "count" ,
230
- has_min_periods = False ,
231
- fill_value = 0 ,
232
- raw = raw ,
233
- series = series ,
234
- frame = frame ,
235
- )
236
-
237
-
238
- def test_rolling_mean (raw , series , frame ):
239
- _check_moment_func (np .mean , name = "mean" , raw = raw , series = series , frame = frame )
240
-
241
-
242
206
@td .skip_if_no_scipy
243
207
def test_cmov_mean ():
244
208
# GH 8238
@@ -733,13 +697,7 @@ def test_cmov_window_special_linear_range(win_types_special):
733
697
tm .assert_series_equal (xp , rs )
734
698
735
699
736
- def test_rolling_median (raw , series , frame ):
737
- _check_moment_func (np .median , name = "median" , raw = raw , series = series , frame = frame )
738
-
739
-
740
- def test_rolling_min (raw , series , frame ):
741
- _check_moment_func (np .min , name = "min" , raw = raw , series = series , frame = frame )
742
-
700
+ def test_rolling_min_min_periods ():
743
701
a = pd .Series ([1 , 2 , 3 , 4 , 5 ])
744
702
result = a .rolling (window = 100 , min_periods = 1 ).min ()
745
703
expected = pd .Series (np .ones (len (a )))
@@ -749,9 +707,7 @@ def test_rolling_min(raw, series, frame):
749
707
pd .Series ([1 , 2 , 3 ]).rolling (window = 3 , min_periods = 5 ).min ()
750
708
751
709
752
- def test_rolling_max (raw , series , frame ):
753
- _check_moment_func (np .max , name = "max" , raw = raw , series = series , frame = frame )
754
-
710
+ def test_rolling_max_min_periods ():
755
711
a = pd .Series ([1 , 2 , 3 , 4 , 5 ], dtype = np .float64 )
756
712
b = a .rolling (window = 100 , min_periods = 1 ).max ()
757
713
tm .assert_almost_equal (a , b )
@@ -855,20 +811,6 @@ def test_rolling_quantile_param():
855
811
ser .rolling (3 ).quantile ("foo" )
856
812
857
813
858
- def test_rolling_std (raw , series , frame ):
859
- _check_moment_func (
860
- lambda x : np .std (x , ddof = 1 ), name = "std" , raw = raw , series = series , frame = frame
861
- )
862
- _check_moment_func (
863
- lambda x : np .std (x , ddof = 0 ),
864
- name = "std" ,
865
- ddof = 0 ,
866
- raw = raw ,
867
- series = series ,
868
- frame = frame ,
869
- )
870
-
871
-
872
814
def test_rolling_std_1obs ():
873
815
vals = pd .Series ([1.0 , 2.0 , 3.0 , 4.0 , 5.0 ])
874
816
@@ -905,20 +847,6 @@ def test_rolling_std_neg_sqrt():
905
847
assert np .isfinite (b [2 :]).all ()
906
848
907
849
908
- def test_rolling_var (raw , series , frame ):
909
- _check_moment_func (
910
- lambda x : np .var (x , ddof = 1 ), name = "var" , raw = raw , series = series , frame = frame
911
- )
912
- _check_moment_func (
913
- lambda x : np .var (x , ddof = 0 ),
914
- name = "var" ,
915
- ddof = 0 ,
916
- raw = raw ,
917
- series = series ,
918
- frame = frame ,
919
- )
920
-
921
-
922
850
@td .skip_if_no_scipy
923
851
def test_rolling_skew (raw , series , frame ):
924
852
from scipy .stats import skew
0 commit comments