From 92f0a26eaf60ef51b11705b943e0279657fbc6bc Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 26 Aug 2024 09:00:23 +0100 Subject: [PATCH 1/2] Add tests for floating point transforms in FixedScaleOffset --- numcodecs/tests/test_fixedscaleoffset.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/numcodecs/tests/test_fixedscaleoffset.py b/numcodecs/tests/test_fixedscaleoffset.py index daa64220..f061aa2a 100644 --- a/numcodecs/tests/test_fixedscaleoffset.py +++ b/numcodecs/tests/test_fixedscaleoffset.py @@ -36,12 +36,20 @@ def test_encode_decode(): check_encode_decode(arr, codec, precision=precision) -def test_encode(): +@pytest.mark.parametrize( + "offset, scale, expected", + [ + (1000, 10, [0, 6, 11, 17, 22, 28, 33, 39, 44, 50]), + (1002.5, 10, [-25, -19, -14, -8, -3, 3, 8, 14, 19, 25]), + (1000, 0.5, [0, 0, 1, 1, 1, 1, 2, 2, 2, 2]), + ], +) +def test_encode(offset: float, scale: float, expected: list[int]): dtype = ' Date: Thu, 7 Nov 2024 20:47:17 +0000 Subject: [PATCH 2/2] Fix pytest argument --- numcodecs/tests/test_fixedscaleoffset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numcodecs/tests/test_fixedscaleoffset.py b/numcodecs/tests/test_fixedscaleoffset.py index f061aa2a..337e893e 100644 --- a/numcodecs/tests/test_fixedscaleoffset.py +++ b/numcodecs/tests/test_fixedscaleoffset.py @@ -37,7 +37,7 @@ def test_encode_decode(): @pytest.mark.parametrize( - "offset, scale, expected", + ("offset", "scale", "expected"), [ (1000, 10, [0, 6, 11, 17, 22, 28, 33, 39, 44, 50]), (1002.5, 10, [-25, -19, -14, -8, -3, 3, 8, 14, 19, 25]),