Bit Array

class npstructures.BitArray(data: ndarray, bit_stride: int, shape: tuple, offset: int = 0)[source]
classmethod pack(array: ndarray, bit_stride: int) BitArray[source]

Pack a numpy array into n-bit encoded array

Pack an array where all values can be represented in bit_stride bits into a bit_stride-bit encoded array

Parameters:
cls
arraynp.ndarray

Values to be packed

bit_strideint

N-bits per entry

Returns:
“BitArray”

BitArray with packed values

sliding_window(window_size: int) ndarray[source]

Return sliding windows of bit-packed values

For window sizes less than n_entries_per_register. Return one register per window

Parameters:
window_sizeint

how many entries in each window

Returns:
np.ndarray

self.size-window_size+1 windows

unpack() ndarray[source]

Unpack n-bit encoded data into normal numpy array

Returns:
np.ndarray

Unpacked data