sdr.unpack(x: ArrayLike, bpe: int, dtype: DTypeLike | None = None) NDArray[int_]

Unpacks an array with multiple bits per element into a binary array.

The data is assumed to have the most significant bit first.

Parameters:
x: ArrayLike

The input array with bpe bits per element.

bpe: int

The number of bits per element in the input array.

dtype: DTypeLike | None = None

The data type of the output array. If None, numpy.uint8 is used.

Returns:

The unpacked binary data with 1 bit per element.

Examples

In [1]: sdr.unpack([2, 0, 3, 1], 2)
Out[1]: array([1, 0, 0, 0, 1, 1, 0, 1], dtype=uint8)

In [2]: sdr.unpack([4, 3, 2], 3)
Out[2]: array([1, 0, 0, 0, 1, 1, 0, 1, 0], dtype=uint8)