leniax.loader package
- leniax.loader.make_array_compressible(cells)[source]
Round values so the array can be encoded using a subset of utf-8 characters
- Parameters
cells (jax._src.numpy.ndarray.ndarray) – Cells state.
- Returns
The rounded cells state
- Return type
jax._src.numpy.ndarray.ndarray
- leniax.loader.compress_array(cells)[source]
Compress a cells state into a base64 utf-8 string.
Note
The cells state in float32 is first encoded as int32.
That state is then flattened and converted into raw bytes of length 4 in little endian.
Finally we prepend the total number of bytes of the state and append the shape as bytes.
Finally, we compress the array using the gzip algorithm and the resulting bytes are encoded as base64 in the utf-8 encoding.
- Parameters
cells (jax._src.numpy.ndarray.ndarray) – Cells state
- Returns
Cells state encoded as a string.
- Return type
str
- leniax.loader.decompress_array(string_cells, nb_dims=0)[source]
Best effort helpers which tries all existing decompress function built so far
- Parameters
string_cells (str) – A string encoded cells state.
nb_dims (int) – the number of dimensions in the cells state.
- Returns
The decoded cells state array.
- Return type
jax._src.numpy.ndarray.ndarray
- leniax.loader.decompress_array_gzip(string_cells)[source]
Decompress string encoded cells state using the gzip algorithm
- Parameters
string_cells (str) – A base64 string encoded cells state.
- Returns
The decoded cells state array.
- Return type
jax._src.numpy.ndarray.ndarray
- leniax.loader.decompress_array_base64(string_cells)[source]
Decompress string encoded cells state using only the base64 algorithm
- Parameters
string_cells (str) – A base64 string encoded cells state.
- Returns
The decoded cells state array.
- Return type
jax._src.numpy.ndarray.ndarray
- leniax.loader.ch2val(c)[source]
Map characters to integers
- Parameters
c (str) – A character.
- Returns
An integer.
- Return type
int
- leniax.loader.val2ch(v)[source]
Map integers to characters
- Parameters
v (int) – An integer
- Returns
A character.
- Return type
str
- leniax.loader.load_raw_cells(config, use_init_cells=True)[source]
Load and decompress cells state contained in a Leniax configuration.
- Parameters
config (Dict) – Leniax configuration
use_init_cells (bool) – Set to
Trueto use theinit_cellsconfiguration property.
- Returns
A Leniax cells state.
- Return type
jax._src.numpy.ndarray.ndarray