Skip to content

Commit

Permalink
Disable PCodec if dependencies are unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Nov 18, 2024
1 parent 145f57c commit 0a8d9e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 3 additions & 2 deletions numcodecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@

register_codec(Fletcher32)

from numcodecs.pcodec import PCodec
with suppress(ImportError):
from numcodecs.pcodec import PCodec

register_codec(PCodec)
register_codec(PCodec)
8 changes: 1 addition & 7 deletions numcodecs/pcodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from numcodecs.abc import Codec
from numcodecs.compat import ensure_contiguous_ndarray

try:
from pcodec import ChunkConfig, ModeSpec, PagingSpec, standalone
except ImportError: # pragma: no cover
standalone = None
from pcodec import ChunkConfig, ModeSpec, PagingSpec, standalone


DEFAULT_MAX_PAGE_N = 262144
Expand Down Expand Up @@ -49,9 +46,6 @@ def __init__(
# TODO one day, add support for the Try* mode specs
mode_spec: Literal['auto', 'classic'] = 'auto',
):
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

0 comments on commit 0a8d9e2

Please sign in to comment.