From 8dd3a6ed14e6e682bf617927349d577f2fa32190 Mon Sep 17 00:00:00 2001 From: Liang Jingyi <124090346@link.cuhk.edu.cn> Date: Thu, 15 Oct 2026 14:51:54 +0800 Subject: [PATCH] test: add BitRound compatibility fixtures Related to #348. Verify fixed float32/float64 data with registry-restored JSON configurations. --- docs/release.md | 3 ++ fixture/bitround/README.md | 54 +++++++++++++++++++++++ fixture/bitround/codec.00/config.json | 4 ++ fixture/bitround/codec.00/encoded.00.dat | Bin 0 -> 16 bytes fixture/bitround/codec.00/encoded.01.dat | Bin 0 -> 32 bytes fixture/bitround/codec.01/config.json | 4 ++ fixture/bitround/codec.01/encoded.00.dat | Bin 0 -> 16 bytes fixture/bitround/codec.01/encoded.01.dat | Bin 0 -> 32 bytes tests/test_bitround.py | 37 ++++++++++++++++ 9 files changed, 102 insertions(+) create mode 100644 fixture/bitround/README.md create mode 100644 fixture/bitround/codec.00/config.json create mode 100644 fixture/bitround/codec.00/encoded.00.dat create mode 100644 fixture/bitround/codec.00/encoded.01.dat create mode 100644 fixture/bitround/codec.01/config.json create mode 100644 fixture/bitround/codec.01/encoded.00.dat create mode 100644 fixture/bitround/codec.01/encoded.01.dat diff --git a/docs/release.md b/docs/release.md index 1f439a9c9..ad421d6c1 100644 --- a/docs/release.md +++ b/docs/release.md @@ -16,6 +16,9 @@ (release_0.17.0)= +* Add fixed BitRound compatibility data and test decoding with a codec restored + from its JSON configuration through the registry, contributing to {issue}`348`. + * Allow building against a system Zlib. Note, this is only required if blosc is still vendored, and a vendored Zlib is no longer built if blosc is not. By {user}`Elliott Sales de Andrade `, {issue}`860` diff --git a/fixture/bitround/README.md b/fixture/bitround/README.md new file mode 100644 index 000000000..a4c86a5af --- /dev/null +++ b/fixture/bitround/README.md @@ -0,0 +1,54 @@ +# BitRound compatibility data + +These fixtures establish a compatibility baseline from Numcodecs commit +`1f83681cf310ac9aac8041ed6ff4a5dcc42a7aad` +(`0.17.1.dev1+g1f83681cf`), generated with Python 3.13.5 and NumPy 2.5.4 on +little-endian Windows x86_64. They are not fixtures from an earlier release. + +The input is `[1.15625, -1.15625, 2.6875, -2.6875]`, shape `(4,)`. +`encoded.00.dat` stores the encoded `Ow`U8Ie literal 0 HcmV?d00001 diff --git a/fixture/bitround/codec.00/encoded.01.dat b/fixture/bitround/codec.00/encoded.01.dat new file mode 100644 index 0000000000000000000000000000000000000000..3651a100e63eb93bb7b90124f698bc6e7f36ef34 GIT binary patch literal 32 YcmZQz0D&*|V2a_(ehAIt0HqHA06-Q4?*IS* literal 0 HcmV?d00001 diff --git a/fixture/bitround/codec.01/config.json b/fixture/bitround/codec.01/config.json new file mode 100644 index 000000000..1b2dc73bc --- /dev/null +++ b/fixture/bitround/codec.01/config.json @@ -0,0 +1,4 @@ +{ + "id": "bitround", + "keepbits": 3 +} diff --git a/fixture/bitround/codec.01/encoded.00.dat b/fixture/bitround/codec.01/encoded.00.dat new file mode 100644 index 0000000000000000000000000000000000000000..a0badb6f80381a9f04eb5b7ee8f1e29ceca8e542 GIT binary patch literal 16 WcmZQzm|)MqFkwFfgMkAO9{>Ov`U8Ie literal 0 HcmV?d00001 diff --git a/fixture/bitround/codec.01/encoded.01.dat b/fixture/bitround/codec.01/encoded.01.dat new file mode 100644 index 0000000000000000000000000000000000000000..68d28fd229953685efe41520b6cf533a75cced35 GIT binary patch literal 32 YcmZQz0D({TV2a_>ehAIx0HqHA06*3P?*IS* literal 0 HcmV?d00001 diff --git a/tests/test_bitround.py b/tests/test_bitround.py index 3929e43c6..9cb1bac3c 100644 --- a/tests/test_bitround.py +++ b/tests/test_bitround.py @@ -1,7 +1,11 @@ +import json +from pathlib import Path + import numpy as np import pytest from numcodecs.bitround import BitRound, max_bits +from numcodecs.registry import get_codec # adapted from https://github.com/milankl/BitInformation.jl/blob/main/test/round_nearest.jl @@ -79,3 +83,36 @@ def test_errors(): BitRound(keepbits=10).encode(np.array([0])) with pytest.raises(ValueError): BitRound(-1) + + +@pytest.mark.parametrize(('array_index', 'dtype'), [(0, '