Skip to content

containers

SlottedDict

Bases: Generic[T]

A generic slotted class for dictionary-like behavior.

This class implements all functions that dict objects provide, automatically loading underlying data sources if required, then "forwarding" the functions to the wrapped self.data dictionary.

Keys of this dictionary are always strings (e.g., paper IDs or person IDs), while the type of values depends on the subclass.

Attributes:

Name Type Description
data dict[str, T]

The wrapped data dictionary.

is_data_loaded bool

Flag that defaults to True. Subclasses can set this to False to indicate that self.load() must be called before any data can be accessed; in that case, they also have to implement the load function.

load

load()

Load the data. Must be implemented by all inheriting classes if they set is_data_loaded=False.

Raises:

Type Description
NotImplementedError