DatasetWrapperMixin#
- class tpcp.DatasetWrapperMixin[source]#
Provide common behavior for datasets that wrap another dataset.
This mixin expands the index of
wrapped_datasetthrough_create_wrapped_index, links the wrapper’s initial grouping to the wrapped dataset, and resolves the source datapoint represented by a wrapper datapoint throughwrapped_datapoint.The mixin deliberately does not inherit from
Dataset. A concrete wrapper must inherit from both this mixin and the domain-specific dataset interface implemented by the wrapped dataset.Important
DatasetWrapperMixinmust be listed before the dataset base class. The order controls Python’s method resolution order and ensures that this mixin’screate_indeximplementation is used. Reversing the bases raises aTypeErrorwhen the wrapper class is defined.- Attributes:
wrapped_datapointReturn the wrapped datapoint represented by the current wrapper group.
Examples
The mixin comes first and the shared dataset interface comes second:
class AugmentedDataset( DatasetWrapperMixin[SourceDataset], SourceDataset, ): _wrapper_groupby_cols = ("augmentation",) def _create_wrapped_index(self, source_index): ...
Methods
Create the wrapper index and link its initial grouping to the wrapped dataset.
- __init__(*args, **kwargs)#
- create_index() DataFrame[source]#
Create the wrapper index and link its initial grouping to the wrapped dataset.
- property wrapped_datapoint: WrappedDatasetT#
Return the wrapped datapoint represented by the current wrapper group.