diff --git a/docs/release.rst b/docs/release.rst index 5c8f83b9..4402ad15 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -41,6 +41,10 @@ Fixes ~~~~~ * Fixes issue with ``Delta`` Zarr 3 codec not working with ``astype``. By :user:`Norman Rzepka `, :issue:`664` +* Cleanup ``PCodec`` soft dependency. + Previously importing ``numcodecs.pcodec`` would work if ``pcodec`` is not installed, + but now it will fail to import. This mirrors the behaviour of other optional dependencies. + By :user:`John Kirkham `, :issue:`647` * Fixes issues with the upcoming ``zarr`` 3.0.0 release. By :user:`Norman Rzepka `, :issue:`675` diff --git a/numcodecs/pcodec.py b/numcodecs/pcodec.py index da063ae5..995a1ce0 100644 --- a/numcodecs/pcodec.py +++ b/numcodecs/pcodec.py @@ -2,12 +2,7 @@ from numcodecs.abc import Codec from numcodecs.compat import ensure_contiguous_ndarray - -try: - from pcodec import ChunkConfig, DeltaSpec, ModeSpec, PagingSpec, standalone -except ImportError: # pragma: no cover - standalone = None - +from pcodec import ChunkConfig, DeltaSpec, ModeSpec, PagingSpec, standalone DEFAULT_MAX_PAGE_N = 262144 @@ -58,9 +53,6 @@ def __init__( delta_encoding_order: int | None = None, equal_pages_up_to: int = DEFAULT_MAX_PAGE_N, ): - if standalone is None: # pragma: no cover - raise ImportError("pcodec must be installed to use the PCodec codec.") - # note that we use `level` instead of `compression_level` to # match other codecs self.level = level diff --git a/numcodecs/tests/test_pcodec.py b/numcodecs/tests/test_pcodec.py index 63a2fb51..b35f618e 100644 --- a/numcodecs/tests/test_pcodec.py +++ b/numcodecs/tests/test_pcodec.py @@ -1,11 +1,8 @@ import numpy as np import pytest -from numcodecs.pcodec import PCodec - try: - # initializing codec triggers ImportError - PCodec() + from numcodecs.pcodec import PCodec except ImportError: # pragma: no cover pytest.skip("pcodec not available", allow_module_level=True)