brainstate.util.unfreeze#
- brainstate.util.unfreeze(x)[source]#
Convert a FrozenDict to a regular dict.
Recursively converts FrozenDict instances to mutable dicts.
- Parameters:
x (
FrozenDict[TypeVar(K),TypeVar(V)] |dict[TypeVar(K),TypeVar(V)]) – A FrozenDict or dict to unfreeze.- Returns:
A mutable dictionary.
- Return type:
See also
freezeConvert a mapping to a FrozenDict.
FrozenDictThe immutable dictionary class.
Examples
>>> from brainstate.util import FrozenDict, unfreeze >>> fd = FrozenDict({'a': 1, 'b': {'c': 2}}) >>> d = unfreeze(fd) >>> isinstance(d, dict) True >>> isinstance(d['b'], dict) # Nested FrozenDicts are unfrozen True >>> d['a'] = 10 # Can modify the result