gluonts.core.serde.flat module

Flat encoding for serde.

flat.encode always returns a flat dictionary, where keys contain information for nested objects:

class Inner(NamedTuple):
    val: int

class Outer(NamedTuple):
    inner: Inner

value = Outer(inner=Inner(val=42))

assert encode(value) == {
    '()': '__main__.Outer',
    'inner.()': '__main__.Inner',
    'inner.val': 42},
}
gluonts.core.serde.flat.clone(data, kwargs=None)[source]

Create a copy of a given value, by calling encode and decode on it.

If kwargs is provided, it’s possible to overwrite nested values.

gluonts.core.serde.flat.decode(data: dict) → Any[source]
gluonts.core.serde.flat.encode(obj) → dict[source]

Encode a given object into a flat-dictionary.

It uses the default-encoding, to then flatten the output.

gluonts.core.serde.flat.get_args(data)[source]
gluonts.core.serde.flat.join(a, b, sep='.')[source]

Joins a and b using sep.

gluonts.core.serde.flat.nest(data)[source]