Skip to content

Commit 32545ec

Browse files
jakirkhamdstansbypre-commit-ci[bot]
authored
Cleanup PCodec soft dependency (#647)
* Disable `PCodec` if dependencies are unavailable * Run `isort` on `pcodec` module * Add release note * Update release note * style: pre-commit fixes --------- Co-authored-by: David Stansby <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d8d53bb commit 32545ec

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
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/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

0 commit comments

Comments
 (0)