@@ -36,12 +36,20 @@ def test_encode_decode():
3636 check_encode_decode (arr , codec , precision = precision )
3737
3838
39- def test_encode ():
39+ @pytest .mark .parametrize (
40+ ("offset" , "scale" , "expected" ),
41+ [
42+ (1000 , 10 , [0 , 6 , 11 , 17 , 22 , 28 , 33 , 39 , 44 , 50 ]),
43+ (1002.5 , 10 , [- 25 , - 19 , - 14 , - 8 , - 3 , 3 , 8 , 14 , 19 , 25 ]),
44+ (1000 , 0.5 , [0 , 0 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 ]),
45+ ],
46+ )
47+ def test_encode (offset : float , scale : float , expected : list [int ]):
4048 dtype = '<f8'
41- astype = '|u1'
42- codec = FixedScaleOffset (scale = 10 , offset = 1000 , dtype = dtype , astype = astype )
43- arr = np .linspace (1000 , 1001 , 10 , dtype = dtype )
44- expect = np .array ([ 0 , 1 , 2 , 3 , 4 , 6 , 7 , 8 , 9 , 10 ] , dtype = astype )
49+ astype = np . int16
50+ codec = FixedScaleOffset (scale = scale , offset = offset , dtype = dtype , astype = astype )
51+ arr = np .linspace (1000 , 1005 , 10 , dtype = dtype )
52+ expect = np .array (expected , dtype = astype )
4553 actual = codec .encode (arr )
4654 assert_array_equal (expect , actual )
4755 assert np .dtype (astype ) == actual .dtype
0 commit comments