Skip to content

Commit c1991e4

Browse files
committed
Merge branch 'feat/numcodecs-protocol' of github.com:d-v-b/zarr-python into feat/numcodecs-protocol
2 parents 413573a + ccaaa65 commit c1991e4

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ coverage:
33
patch:
44
default:
55
target: auto
6+
informational: true
67
project:
78
default:
89
target: auto

src/zarr/abc/numcodec.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,60 @@
66
class Numcodec(Protocol):
77
"""
88
A protocol that models the ``numcodecs.abc.Codec`` interface.
9+
10+
This protocol should be considered experimental; expect the typing for `buf`, and `out` to become stricter.
911
"""
1012

1113
codec_id: str
1214

1315
def encode(self, buf: Any) -> Any: ...
16+
"""Encode data in `buf`.
17+
18+
Parameters
19+
----------
20+
buf
21+
Data to be encoded. May be any object supporting the new-style
22+
buffer protocol.
23+
24+
Returns
25+
-------
26+
enc
27+
Encoded data. May be any object supporting the new-style buffer
28+
protocol.
29+
"""
1430

1531
def decode(self, buf: Any, out: Any | None = None) -> Any: ...
32+
"""
33+
Decode data in `buf`.
34+
35+
Parameters
36+
----------
37+
buf : Any
38+
Encoded data. May be any object supporting the new-style buffer
39+
protocol.
40+
out : Any
41+
Writeable buffer to store decoded data. N.B. if provided, this buffer must
42+
be exactly the right size to store the decoded data.
43+
44+
Returns
45+
-------
46+
dec : Any
47+
Decoded data. May be any object supporting the new-style
48+
buffer protocol.
49+
"""
1650

1751
def get_config(self) -> Any: ...
52+
"""
53+
Return a dictionary holding configuration parameters for this
54+
codec. Must include an 'id' field with the codec identifier. All
55+
values must be compatible with JSON encoding.
56+
"""
1857

1958
@classmethod
2059
def from_config(cls, config: Any) -> Self: ...
60+
"""
61+
Instantiate codec from a configuration object.
62+
"""
2163

2264

2365
def _is_numcodec_cls(obj: object) -> TypeGuard[type[Numcodec]]:

0 commit comments

Comments
 (0)