numcodecs_zero

numcodecs_zero

ZeroCodec for the numcodecs buffer compression API.

Classes:

  • ZeroCodec

    Codec that decodes to an all-zero array of the same data type and shape as

ZeroCodec

Bases: Codec

Codec that decodes to an all-zero array of the same data type and shape as the original data.

Encoding produces a bytestring containing information on the data type and shape.

Methods:

  • encode

    Encode the buffer information.

  • decode

    Decode the buffer information.

codec_id class-attribute instance-attribute

codec_id: str = 'zero'

encode

encode(buf: Buffer) -> bytes

Encode the buffer information.

Parameters:
  • buf (Buffer) –

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

Returns:
  • enc( bytes ) –

    Encoded buffer information as a bytestring.

decode

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

Decode the buffer information.

Parameters:
  • buf (Buffer) –

    Encoded buffer information. 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. The decoded data will be all-zero after decoding.