ExZarr.Gallery.Pack (ExZarr v1.1.0)
View SourceSmall helpers for Livebook tutorials: pack/unpack Elixir numbers into the
row-major binaries expected by ExZarr.Array.get_slice/2 and set_slice/3.
This module is intentionally tiny and dependency-free.
Summary
Functions
Packs a flat list of numbers into a binary for the given dtype.
Unpacks a binary into a flat list of numbers for the given dtype.
Types
Functions
@spec itemsize(
:float32
| :float64
| :int16
| :int32
| :int64
| :int8
| :uint16
| :uint32
| :uint64
| :uint8
) :: 1 | 2 | 4 | 8
Packs a flat list of numbers into a binary for the given dtype.
Notes:
- ExZarr uses little-endian primitives.
- For signed ints we use
signed-little. - For floats we use IEEE 754
float-little.
Unpacks a binary into a flat list of numbers for the given dtype.