MCPcopy Create free account
hub / github.com/SHAILAB-IPEC/OpenFly-Platform / tree_map

Function tree_map

train/datasets/data_utils.py:38–40  ·  view source on GitHub ↗

Maps a function over a nested dictionary.

(fn: Callable, tree: dict)

Source from the content-addressed store, hash-verified

36
37
38def tree_map(fn: Callable, tree: dict) -> dict:
39 """Maps a function over a nested dictionary."""
40 return {k: tree_map(fn, v) if isinstance(v, dict) else fn(v) for k, v in tree.items()}
41
42
43def tree_map_with_key(fn: Callable, tree: dict, keys: Sequence = ()) -> dict:

Callers 1

make_dataset_from_rldsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected