generic.Dataset#

class maite.protocols.generic.Dataset(*args, **kwargs)[source]#

Generic version of a protocol that specifies datum-level random access to a data source.

Implementers must provide index lookup (via __getitem__(ind: int, /) method) and support len (via __len__() method). Data elements returned via __getitem__ correspond to tuples of InputType, TargetType, and DatumMetadataType. The shape/value semantics of these three types are dictated by the concrete types used to specialize this generic.

Additionally, Datasets are expected to contain a metadata attribute of type DatasetMetadata with general information about the data source.

Note: In practice, this class is specialized within AI-problem specific submodules using structural types for InputType, TargetType, and DatumMetadataType. Implementing this class directly (i.e., without specializing on concrete types) is not recommended. Static type checkers will effectively consider all non-specified type parameters as Any-type, effectively masking potential type incompatibilities.