itacart.serialization.data_tree_blob.slice_data_tree

itacart.serialization.data_tree_blob.slice_data_tree(blob, cell)[source]

The sub-tree of a node, with the path that reaches it, as a new blob.

The descendants of a node are one contiguous run of every level, so the slice copies runs. The ancestors on the path keep their level values, and their pyramid values become the aggregate of the slice alone.

Parameters:
Return type:

bytes

Returns:

A DataTreeBlob with the same variables and observation resolution.

Raises:

Example

>>> n = DataVariable("n", "u32", op="sum", leaf_max=1)
>>> blob = encode_data_tree(
...     {"NE(0625/0451(1))": {"n": 1}, "NE(0625/0451(2))": {"n": 1}}, [n]
... )
>>> list(decode_data_tree(slice_data_tree(blob, "NE(0625/0451(2))")))
['NE', 'NE(0625/0451)', 'NE(0625/0451(2))']