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:
- Returns:
A DataTreeBlob with the same variables and observation resolution.
- Raises:
InvalidIndexError – If the cell is malformed.
NonExistentCellError – If it names no cell.
NonAtomicIndexError – If it holds more than one cell.
SerializationError – If the blob holds no node for it.
MalformedBlobError – If the frame is malformed.
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))']