shnitsel.data.tree.data_leaf#
Attributes#
Classes#
Class to represent a leaf node holding data in the ShnitselDB tree hierarchy. |
|
Helper class to encapsulate data that is not immediately accessible but may be provided by asynchronous loading or by |
|
Class to hold data in a leaf of the tree structure, |
Module Contents#
- DataType#
- ResType#
- NewChildType#
- class DataLeaf(*, name=None, data=None, **kwargs)#
Bases:
Generic[DataType],shnitsel.data.tree.node.TreeNode[None,DataType]Class to represent a leaf node holding data in the ShnitselDB tree hierarchy.
May be inherited from to provide leaves with more advanced features like provision of delayed results for support of parallel processing or delayed loading from disc, etc.
- Parameters:
name (str | None)
data (DataType | None)
- construct_copy(children: Mapping[Hashable, None] | None = None, dtype: None = None, data: DataType | None = None, **kwargs) Self#
- construct_copy(children: None = None, dtype: type[ResType] | types.UnionType | None = None, data: ResType | None = None, **kwargs) DataLeaf[ResType]
- construct_copy(children: Mapping[Hashable, NewChildType] | None = None, dtype: type[ResType] | types.UnionType | None = None, data: None = None, **kwargs) DataLeaf[ResType]
Helper function to create a copy of this tree structure, but with potential changes to metadata or data
Parameters:#
- data: ResType | None, optional
Data to replace the current data in the copy of this node
- children: None, optional
Parameter not supported by this type of node.
- dtype: type[ResType] | TypeForm[ResType], optional
The data type of the data in the copy constructed tree.
- raises AssertionError:
If dtype is set without a new data entry being provided
- raises Returns::
- raises ———–:
- Self
A copy of this node with recursively copied children if data is not set .
- DataLeaf[ResType]
A new leaf with a new data type if data is provided.
- group_children_by(key_func=None, group_leaves_only=False, recurse=True)#
Specialization of the grouping operation for leaf nodes.
Simply returns a copy of the current node.
- class ProvidesDelayedData#
Bases:
Generic[DataType],ProtocolHelper class to encapsulate data that is not immediately accessible but may be provided by asynchronous loading or by computation in parallel/another process.
- get_data()#
May be blocking if async processing is required
- Return type:
DataType
- class DelayedDataLeaf(*, name=None, data_provider=None, attrs=None)#
-
Class to hold data in a leaf of the tree structure, where the data is not immediately accessible but may be the delayed result of asynchronous processing.
- Parameters:
name (str | None)
data_provider (ProvidesDelayedData[DataType] | None)
attrs (Mapping[str, Any] | None)
- _data_provider: ProvidesDelayedData[DataType] | None#
- property data: DataType#
- Return type:
DataType