numcodecs_shuffle
numcodecs_shuffle
TypedByteShuffleCodec for the numcodecs buffer compression API.
Modules:
-
typing–Commonly used type variables.
Classes:
TypedByteShuffleCodec
Bases: Codec
Methods:
-
encode–Shuffles the bytes in the
buffer array while keeping the same shape -
decode–Undoes the shuffling of the bytes in the
buffer array.
encode
Shuffles the bytes in the buffer array while keeping the same shape
and data type. The shuffle size is based on the byte size of the data
type. Shuffling can make typed data such as arrays of integers or
floating point numbers easier to compress for a general-purpose
byte-based compressor.
For instance, the big-endian 32bit integer array
[0xaabbccdd, 0xaabbccdd, 0xaabbccdd, 0xaabbccdd] is shuffled to
[0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd].
| Parameters: |
|---|
| Returns: |
|---|
decode
decode(
buf: ndarray[S, dtype[T]],
out: None | ndarray[S, dtype[T]] = None,
) -> ndarray[S, dtype[T]]
Undoes the shuffling of the bytes in the buffer array.
Since the shuffle size is based on the byte size of the data, the
buffer and out arrays must have the same data type as the array
that was originally shuffled in encode.
For instance, the big-endian 32bit integer array
[0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd] is un-shuffled back
to [0xaabbccdd, 0xaabbccdd, 0xaabbccdd, 0xaabbccdd].
| Parameters: |
|---|
| Returns: |
|---|