-
sdr.pack(x: ArrayLike, bpe: int, dtype: DTypeLike | None =
None
) NDArray[int_] Packs a binary array into an array with multiple bits per element.
The data is assumed to have the most significant bit first. If there are not enough bits in the input array to fill the last element of the output array, the remaining bits are filled with zeros.
Examples¶
In [1]: sdr.pack([1, 0, 0, 0, 1, 1, 0, 1], 2) Out[1]: array([2, 0, 3, 1], dtype=uint8) In [2]: sdr.pack([1, 0, 0, 0, 1, 1, 0, 1], 3) Out[2]: array([4, 3, 2], dtype=uint8)