numcodecs_huffman

numcodecs_huffman

HuffmanCodec for the numcodecs buffer compression API.

Classes:

  • HuffmanCodec

    Codec that uses Huffman entropy coding to encode the data.

HuffmanCodec

Bases: Codec

Codec that uses Huffman entropy coding to encode the data.

Encoding produces a bytestring containing the Huffman code table and the encoded data.

Methods:

  • encode

    Encode the data in buf.

  • decode

    Decode the data in buf.

codec_id class-attribute instance-attribute

codec_id: str = 'huffman'

encode

encode(buf: Buffer) -> bytes

Encode the data in buf.

Parameters:
  • buf (Buffer) –

    Data to be encoded. May be any object supporting the new-style buffer protocol.

Returns:
  • enc( bytes ) –

    Encoded data as a bytestring.

decode

decode(buf: Buffer, out: None | Buffer = None) -> Buffer

Decode the data in buf.

Parameters:
  • buf (Buffer) –

    Encoded data. Must be an object representing a bytestring, e.g. bytes or a 1D array of np.uint8s etc.

  • out (Buffer, default: None ) –

    Writeable buffer to store decoded data. N.B. if provided, this buffer must be exactly the right size to store the decoded data.

Returns:
  • dec( Buffer ) –

    Decoded data. May be any object supporting the new-style buffer protocol.