@@ -21,5 +21,54 @@ def test_impl(n):
2121 self .assertEqual (count_parfor_OneDs (), 2 )
2222 self .assertTrue (dist_IR_contains ('dist_cumsum' ))
2323
24+ def test_filter (self ):
25+ def test_impl (n ):
26+ df = pd .DataFrame ({'A' : np .ones (n ), 'B' : np .ones (n )})
27+ df1 = df [df .A > .5 ]
28+ return np .sum (df1 .B )
29+
30+ hpat_func = hpat .jit (test_impl )
31+ n = 11
32+ self .assertEqual (hpat_func (n ), test_impl (n ))
33+ self .assertEqual (count_array_REPs (), 0 )
34+ self .assertEqual (count_parfor_REPs (), 0 )
35+
36+ def test_rolling1 (self ):
37+ def test_impl (n ):
38+ df = pd .DataFrame ({'A' : np .ones (n ), 'B' : np .random .ranf (n )})
39+ Ac = df .A .rolling (5 ).sum ()
40+ return Ac .sum ()
41+
42+ hpat_func = hpat .jit (test_impl )
43+ n = 11
44+ self .assertEqual (hpat_func (n ), test_impl (n ))
45+ self .assertEqual (count_array_REPs (), 0 )
46+ self .assertEqual (count_parfor_REPs (), 0 )
47+
48+ def test_rolling2 (self ):
49+ def test_impl (n ):
50+ df = pd .DataFrame ({'A' : np .ones (n ), 'B' : np .random .ranf (n )})
51+ df ['moving average' ] = df .A .rolling (window = 5 , center = True ).mean ()
52+ return df ['moving average' ].sum ()
53+
54+ hpat_func = hpat .jit (test_impl )
55+ n = 11
56+ self .assertEqual (hpat_func (n ), test_impl (n ))
57+ # small input array to mean is REP
58+ self .assertEqual (count_array_REPs (), 1 )
59+ self .assertEqual (count_parfor_REPs (), 0 )
60+
61+ def test_rolling3 (self ):
62+ def test_impl (n ):
63+ df = pd .DataFrame ({'A' : np .ones (n ), 'B' : np .random .ranf (n )})
64+ Ac = df .A .rolling (3 , center = True ).apply (lambda a : a [0 ]+ 2 * a [1 ]+ a [2 ])
65+ return Ac .sum ()
66+
67+ hpat_func = hpat .jit (test_impl )
68+ n = 11
69+ self .assertEqual (hpat_func (n ), test_impl (n ))
70+ self .assertEqual (count_array_REPs (), 0 )
71+ self .assertEqual (count_parfor_REPs (), 0 )
72+
2473if __name__ == "__main__" :
2574 unittest .main ()
0 commit comments