# PackBits

class `numcodecs.packbits.``PackBits`

  Codec to pack elements of a boolean array into bits in a uint8 array.

  Notes

  The first element of the encoded array stores the number of bits that were padded to complete the final byte.

  Examples

      >>> import numcodecs
      >>> import numpy as np
      >>> codec = numcodecs.PackBits()
      >>> x = np.array([True, False, False, True], dtype=bool)
      >>> y = codec.encode(x)
      >>> y
      array([  4, 144], dtype=uint8)
      >>> z = codec.decode(y)
      >>> z
      array([ True, False, False,  True])

  `codec_id` = 'packbits'
  `encode`(buf)

    Encode data in buf.

    Parameters:

    buf : buffer-like

    > Data to be encoded. May be any object supporting the new-style buffer protocol or array.array under Python 2.

    Returns:

    enc : buffer-like

    > Encoded data. May be any object supporting the new-style buffer protocol or array.array under Python 2.

  `decode`(buf, out=None)

    Decode data in buf.

    Parameters:

    buf : buffer-like

    > Encoded data. May be any object supporting the new-style buffer protocol or array.array under Python 2.

    out : buffer-like, optional

    > 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-like

    > Decoded data. May be any object supporting the new-style buffer protocol or array.array under Python 2.

  `get_config`()

    Return a dictionary holding configuration parameters for this codec. Must include an ‘id’ field with the codec identifier. All values must be compatible with JSON encoding.

  classmethod `from_config`(config)

    Instantiate codec from a configuration object.