9
9
@pytest .mark .parametrize (
10
10
"length, chunks, size, step" , [(12 , 6 , 4 , 4 ), (12 , 6 , 4 , 2 ), (12 , 5 , 4 , 4 )]
11
11
)
12
- def test_moving_statistic_1d (length , chunks , size , step ):
13
- values = da .from_array (np .arange (length ), chunks = chunks )
12
+ @pytest .mark .parametrize ("dtype" , [np .int64 , np .float32 , np .float64 ])
13
+ def test_moving_statistic_1d (length , chunks , size , step , dtype ):
14
+ values = da .from_array (np .arange (length , dtype = dtype ), chunks = chunks )
14
15
15
16
stat = moving_statistic (values , np .sum , size = size , step = step , dtype = values .dtype )
16
17
stat = stat .compute ()
17
18
if length % size != 0 or size != step :
18
19
# scikit-allel misses final window in this case
19
20
stat = stat [:- 1 ]
21
+ assert stat .dtype == dtype
20
22
21
23
values_sa = np .arange (length )
22
24
stat_sa = allel .moving_statistic (values_sa , np .sum , size = size , step = step )
@@ -27,8 +29,9 @@ def test_moving_statistic_1d(length, chunks, size, step):
27
29
@pytest .mark .parametrize (
28
30
"length, chunks, size, step" , [(12 , 6 , 4 , 4 ), (12 , 6 , 4 , 2 ), (12 , 5 , 4 , 4 )]
29
31
)
30
- def test_moving_statistic_2d (length , chunks , size , step ):
31
- arr = np .arange (length * 3 ).reshape (length , 3 )
32
+ @pytest .mark .parametrize ("dtype" , [np .int64 , np .float32 , np .float64 ])
33
+ def test_moving_statistic_2d (length , chunks , size , step , dtype ):
34
+ arr = np .arange (length * 3 , dtype = dtype ).reshape (length , 3 )
32
35
33
36
def sum_cols (x ):
34
37
return np .sum (x , axis = 0 )
@@ -39,6 +42,7 @@ def sum_cols(x):
39
42
if length % size != 0 or size != step :
40
43
# scikit-allel misses final window in this case
41
44
stat = stat [:- 1 ]
45
+ assert stat .dtype == dtype
42
46
43
47
values_sa = arr
44
48
stat_sa = allel .moving_statistic (values_sa , sum_cols , size = size , step = step )
0 commit comments