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

Add BaseCodec to the docs #2290

Merged
merged 1 commit into from
Oct 5, 2024
Merged
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
15 changes: 10 additions & 5 deletions src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from zarr.core.indexing import SelectorTuple

__all__ = [
"BaseCodec",
"ArrayArrayCodec",
"ArrayBytesCodec",
"ArrayBytesCodecPartialDecodeMixin",
Expand All @@ -34,11 +35,15 @@
CodecOutput = TypeVar("CodecOutput", bound=NDBuffer | Buffer)


class _Codec(Metadata, Generic[CodecInput, CodecOutput]):
class BaseCodec(Metadata, Generic[CodecInput, CodecOutput]):
"""Generic base class for codecs.
Please use ArrayArrayCodec, ArrayBytesCodec or BytesBytesCodec for subclassing.

Codecs can be registered via zarr.codecs.registry.

Warnings
--------
This class is not intended to be directly, please use
ArrayArrayCodec, ArrayBytesCodec or BytesBytesCodec for subclassing.
"""

is_fixed_size: bool
Expand Down Expand Up @@ -148,19 +153,19 @@ async def encode(
return await _batching_helper(self._encode_single, chunks_and_specs)


class ArrayArrayCodec(_Codec[NDBuffer, NDBuffer]):
class ArrayArrayCodec(BaseCodec[NDBuffer, NDBuffer]):
"""Base class for array-to-array codecs."""

...


class ArrayBytesCodec(_Codec[NDBuffer, Buffer]):
class ArrayBytesCodec(BaseCodec[NDBuffer, Buffer]):
"""Base class for array-to-bytes codecs."""

...


class BytesBytesCodec(_Codec[Buffer, Buffer]):
class BytesBytesCodec(BaseCodec[Buffer, Buffer]):
"""Base class for bytes-to-bytes codecs."""

...
Expand Down