Skip to content

Commit 17f35b4

Browse files
authored
Merge branch 'main' into normanrz-patch-2
2 parents 0236ca3 + 32545ec commit 17f35b4

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

docs/release.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ Fixes
4141
~~~~~
4242
* Fixes issue with ``Delta`` Zarr 3 codec not working with ``astype``.
4343
By :user:`Norman Rzepka <normanrz>`, :issue:`664`
44+
* Cleanup ``PCodec`` soft dependency.
45+
Previously importing ``numcodecs.pcodec`` would work if ``pcodec`` is not installed,
46+
but now it will fail to import. This mirrors the behaviour of other optional dependencies.
47+
By :user:`John Kirkham <jakirkham>`, :issue:`647`
4448
* Fixes issues with the upcoming ``zarr`` 3.0.0 release.
4549
By :user:`Norman Rzepka <normanrz>`, :issue:`675`
4650

numcodecs/delta.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ def encode(self, buf):
6363
enc[0] = arr[0]
6464

6565
# compute differences
66-
# using np.subtract for in-place operations
67-
if arr.dtype == bool:
68-
np.not_equal(arr[1:], arr[:-1], out=enc[1:])
69-
else:
70-
np.subtract(arr[1:], arr[:-1], out=enc[1:])
71-
66+
enc[1:] = np.diff(arr)
7267
return enc
7368

7469
def decode(self, buf, out=None):

numcodecs/pcodec.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
from numcodecs.abc import Codec
44
from numcodecs.compat import ensure_contiguous_ndarray
5-
6-
try:
7-
from pcodec import ChunkConfig, DeltaSpec, ModeSpec, PagingSpec, standalone
8-
except ImportError: # pragma: no cover
9-
standalone = None
10-
5+
from pcodec import ChunkConfig, DeltaSpec, ModeSpec, PagingSpec, standalone
116

127
DEFAULT_MAX_PAGE_N = 262144
138

@@ -58,9 +53,6 @@ def __init__(
5853
delta_encoding_order: int | None = None,
5954
equal_pages_up_to: int = DEFAULT_MAX_PAGE_N,
6055
):
61-
if standalone is None: # pragma: no cover
62-
raise ImportError("pcodec must be installed to use the PCodec codec.")
63-
6456
# note that we use `level` instead of `compression_level` to
6557
# match other codecs
6658
self.level = level

numcodecs/tests/test_pcodec.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import numpy as np
22
import pytest
33

4-
from numcodecs.pcodec import PCodec
5-
64
try:
7-
# initializing codec triggers ImportError
8-
PCodec()
5+
from numcodecs.pcodec import PCodec
96
except ImportError: # pragma: no cover
107
pytest.skip("pcodec not available", allow_module_level=True)
118

numcodecs/tests/test_vlen_bytes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def test_decode_errors():
8484
codec.decode(enc, out=np.zeros(10, dtype='i4'))
8585

8686

87+
# TODO: fix this test on GitHub actions somehow...
88+
# See https://github.com/zarr-developers/numcodecs/issues/683
89+
@pytest.mark.skip("Test is failing on GitHub actions.")
8790
def test_encode_none():
8891
a = np.array([b'foo', None, b'bar'], dtype=object)
8992
codec = VLenBytes()

0 commit comments

Comments
 (0)