Base Condition#

Module for the Base Condition class.

class BaseCondition(**kwargs)[source]#

Bases: ConditionInterface

Base class for all conditions, implementing common functionality.

All specific condition types should inherit from this class and implement the abstract methods of ConditionInterface.

This class is not meant to be instantiated directly.

Initialization of the BaseCondition class.

Parameters:

kwargs (dict) – The keyword arguments representing the data to be stored in the condition.

create_dataloader(dataset, batch_size, automatic_batching, **kwargs)[source]#

Create the DataLoader for the condition.

Parameters:
  • dataset (_ConditionSubset) – The dataset for the DataLoader.

  • batch_size (int) – The batch size for the DataLoader.

  • automatic_batching (bool) – Whether to use automatic batching.

  • kwargs (dict) – Additional keyword arguments for the DataLoader.

Returns:

The DataLoader for the condition.

Return type:

torch.utils.data.DataLoader

switch_dataloader_fn(create_dataloader_fn)[source]#

Switch the dataloader function for the condition.

Parameters:

create_dataloader_fn (Callable) – The new dataloader function to use for the condition.

Returns:

The new dataloader function for the condition.

Return type:

Callable

classmethod automatic_batching_collate_fn(batch)[source]#

Collate function for automatic batching to be used in the DataLoader.

Parameters:

batch (list) – A list of items from the dataset.

Returns:

A collated batch.

Return type:

dict

static collate_fn(batch, condition)[source]#

Collate function for custom batching to be used in the DataLoader.

Parameters:
  • batch (list) – A list of items from the dataset.

  • condition (BaseCondition) – The condition instance.

Returns:

A collated batch.

Return type:

dict

property problem#

The problem associated with this condition.

Returns:

The problem associated with this condition.

Return type:

BaseProblem