Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup PCodec soft dependency #647

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Fixes
~~~~~
* Fixes issue with ``Delta`` Zarr 3 codec not working with ``astype``.
By :user:`Norman Rzepka <normanrz>`, :issue:`664`
* Cleanup ``PCodec`` soft dependency.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Cleanup ``PCodec`` soft dependency.
* 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have something that describes what's changed to users - I've left a suggesiton above

By :user:`John Kirkham <jakirkham>`, :issue:`647`


Improvements
Expand Down
11 changes: 2 additions & 9 deletions numcodecs/pcodec.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
from typing import Literal, Optional

from pcodec import ChunkConfig, DeltaSpec, ModeSpec, PagingSpec, standalone

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


DEFAULT_MAX_PAGE_N = 262144


Expand Down Expand Up @@ -58,9 +54,6 @@ def __init__(
delta_encoding_order: Optional[int] = 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
Expand Down
5 changes: 1 addition & 4 deletions numcodecs/tests/test_pcodec.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Loading