Data Compression

The library comes with some basic data compression routines. They are helpful in simple use cases like:

  • compression of binary arrays

  • run length encoding

  • fixed length encoding of integers

These routines are primarily based on numpy arrays and bitarray based compressed bit arrays. This module doesn’t use JAX.

count_runs_values(input_arr)

Computes run lengths of an array of integers

expand_runs_values(runs, values)

Decodes run lengths to form an array of integers

encode_int_arr_sgn_mag_fl(input_arr, …)

Encodes an array of integers to a bit array using a sign bit and a fixed number of bits per sample for magnitude

decode_int_arr_sgn_mag_fl(input_bit_arr, …)

Decodes an array of integers from a bit array using a sign bit and a fixed number of bits per sample for magnitude

count_binary_runs(input_arr)

Returns the runs of 0s and 1s in a binary map

encode_binary_arr(input_arr)

Encodes a binary array into a bit array via run length encoding

decode_binary_arr(input_bit_arr)

Decodes a binary array from a bit array via run length decoding

binary_compression_ratio(input_arr, output_arr)

Returns the compression ratio of binary array compression algorithm

binary_space_saving_ratio(input_arr, output_arr)

Returns the space saving ratio of binary array compression algorithm