Skip to content

Commit 1c68508

Browse files
committed
support new pcodec delta_spec
1 parent 29995e3 commit 1c68508

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

docs/release.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Release notes
1111
Unreleased
1212
----------
1313

14+
Fixes
15+
~~~~~
16+
* Add support for pcodec v0.3.
17+
By :user:`Sam Levang <slevang>`, :issue:`623`
1418

1519
.. _release_0.14.0:
1620

numcodecs/pcodec.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
except ImportError: # pragma: no cover
99
standalone = None
1010

11+
# backwards compatibility for pcodec<0.3.0
12+
try:
13+
from pcodec import DeltaSpec
14+
except ImportError: # pragma: no cover
15+
DeltaSpec = None
1116

1217
DEFAULT_MAX_PAGE_N = 262144
1318

@@ -62,6 +67,15 @@ def __init__(
6267
def encode(self, buf):
6368
buf = ensure_contiguous_ndarray(buf)
6469

70+
if DeltaSpec is not None:
71+
if self.delta_encoding_order is None:
72+
delta_spec = DeltaSpec.auto()
73+
else:
74+
delta_spec = DeltaSpec.try_consecutive(self.delta_encoding_order)
75+
delta_kwargs = {"delta_spec": delta_spec}
76+
else:
77+
delta_kwargs = {"delta_encoding_order": self.delta_encoding_order}
78+
6579
match self.mode_spec:
6680
case 'auto':
6781
mode_spec = ModeSpec.auto()
@@ -73,9 +87,9 @@ def encode(self, buf):
7387

7488
config = ChunkConfig(
7589
compression_level=self.level,
76-
delta_encoding_order=self.delta_encoding_order,
7790
mode_spec=mode_spec,
7891
paging_spec=paging_spec,
92+
**delta_kwargs,
7993
)
8094
return standalone.simple_compress(buf, config)
8195

numcodecs/tests/test_pcodec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
PCodec(level=9),
2626
PCodec(mode_spec='classic'),
2727
PCodec(equal_pages_up_to=300),
28+
PCodec(delta_encoding_order=2),
2829
]
2930

3031

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ zfpy = [
6868
"numpy<2.0.0",
6969
]
7070
pcodec = [
71-
"pcodec>=0.2,<0.3",
71+
"pcodec>=0.2",
7272
]
7373
crc32c = [
7474
"crc32c>=2.7",

0 commit comments

Comments
 (0)