numcodecs_wasm_pco

Classes:

  • Pco

    Codec providing compression using pco

Pco

Pco(
    delta,
    level,
    mode,
    paging,
    _version="0.2.0",
    delta_encoding_order=None,
    equal_pages_up_to=262144,
    float_mult_base=None,
    float_quant_bits=None,
    int_mult_base=None,
)

Codec providing compression using pco

Parameters:
  • delta (...) –
    • "auto": Automatically detects a detects a good delta encoding.

      This works well most of the time, but costs some compression time and can select a bad delta encoding in adversarial cases.

    • "no-op": Never uses delta encoding.

      This is best if your data is in a random order or adjacent numbers have no relation to each other.

    • "try-consecutive": Tries taking nth order consecutive deltas.

      Supports a delta encoding order up to 7. For instance, 1st order is just regular delta encoding, 2nd is deltas-of-deltas, etc. It is legal to use 0th order, but it is identical to None.

    • "try-lookback": Tries delta encoding according to an extra latent variable of "lookback".

      This can improve compression ratio when there are nontrivial patterns in the array, but reduces compression speed substantially.

    • "try-conv1": Tries delta encoding by subtracting a convolution of the previous delta_encoding_order elements.

      This is best if your numbers have local trends that aren't captured by simply taking differences, and you are willing to accept noticeably reduced decompression speeds.

  • level (...) –

    Compression level, ranging from 0 (weak) over 8 (very good) to 12 (expensive)

  • mode (...) –
    • "auto": Automatically detects a good mode.

      This works well most of the time, but costs some compression time and can select a bad mode in adversarial cases.

    • "classic": Only uses the classic mode

    • "try-float-mult": Tries using the FloatMult mode with a given base.

      Only applies to floating-point types.

    • "try-float-quant": Tries using the FloatQuant mode with the given number of bits of quantization.

      Only applies to floating-point types.

    • "try-int-mult": Tries using the IntMult mode with a given base.

      Only applies to integer types.

  • paging (...) –
    • "equal-pages-up-to": Divide the chunk into equal pages of up to this many numbers.

      For example, with equal pages up to 100,000, a chunk of 150,000 numbers would be divided into 2 pages, each of 75,000 numbers.

  • _version (..., default: = "0.2.0" ) –

    The codec's encoding format version. Do not provide this parameter explicitly.

  • delta_encoding_order (..., default: None ) –

    the order of the delta encoding

  • equal_pages_up_to (..., default: = 262144 ) –

    maximum amount of numbers in a page

  • float_mult_base (..., default: None ) –

    the base for the FloatMult mode

  • float_quant_bits (..., default: None ) –

    the number of bits to which floating-point values are quantized

  • int_mult_base (..., default: None ) –

    the base for the IntMult mode

Methods:

  • decode

    Decode the data in buf.

  • encode

    Encode the data in buf.

  • from_config

    Instantiate the codec from a configuration dict.

  • get_config

    Returns the configuration of the codec.

codec_id class-attribute instance-attribute

codec_id = 'pco.rs'

decode

decode(buf, out=None)

Decode the data in buf.

Parameters:
  • buf (Buffer) –

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

  • 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.

encode

encode(buf)

Encode the data in buf.

Parameters:
  • buf (Buffer) –

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

Returns:
  • enc( Buffer ) –

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

from_config classmethod

from_config(config)

Instantiate the codec from a configuration dict.

Parameters:
  • config (dict) –

    Configuration of the codec.

Returns:
  • codec( Self ) –

    Instantiated codec.

get_config

get_config()

Returns the configuration of the codec.

numcodecs.registry.get_codec(config) can be used to reconstruct this codec from the returned config.

Returns:
  • config( dict ) –

    Configuration of the codec.