src.fairreckitlib.data.filter.filter_config

This module contains the subgroup/filter configurations.

Classes:

FilterConfig: data filter configuration.
FilterPassConfig: data filter pass configuration consisting of multiple filters.
DataSubsetConfig: data subset configuration consisting of multiple filter passes.

This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. © Copyright Utrecht University (Department of Information and Computing Sciences)

 1"""This module contains the subgroup/filter configurations.
 2
 3Classes:
 4
 5    FilterConfig: data filter configuration.
 6    FilterPassConfig: data filter pass configuration consisting of multiple filters.
 7    DataSubsetConfig: data subset configuration consisting of multiple filter passes.
 8
 9This program has been developed by students from the bachelor Computer Science at
10Utrecht University within the Software Project course.
11© Copyright Utrecht University (Department of Information and Computing Sciences)
12"""
13
14from dataclasses import dataclass
15from typing import Any, Dict, List
16
17from ...core.config.config_object import ObjectConfig
18from ...core.config.config_yml import YmlConfig, format_yml_config_list
19from ..set.dataset_constants import KEY_DATASET, KEY_MATRIX
20from .filter_constants import KEY_DATA_FILTER_PASS, KEY_DATA_SUBSET
21
22
23@dataclass
24class FilterConfig(ObjectConfig):
25    """Filter Configuration.
26
27    name: the name of the filter.
28    params: the parameters of the filter.
29    """
30
31
32@dataclass
33class FilterPassConfig(YmlConfig):
34    """Filter Pass Configuration.
35
36    The pass consists of multiple filters that are applied in order.
37
38    filters: list of filter configurations.
39    """
40
41    filters: List[FilterConfig]
42
43    def to_yml_format(self) -> Dict[str, Any]:
44        """Format filter pass configuration to a yml compatible dictionary.
45
46        Returns:
47            a dictionary containing the subgroup configuration.
48        """
49        return {KEY_DATA_FILTER_PASS: format_yml_config_list(self.filters)}
50
51
52@dataclass
53class DataSubsetConfig:
54    """Data Subset Configuration.
55
56    The subset of the data consists of multiple filter passes that are applied
57    on the dataset individually, and thereafter they are merged to create the subset.
58
59    dataset: the name of the dataset.
60    matrix: the name of the dataset matrix.
61    filter_passes: the subset as a list of filter passes.
62    """
63
64    dataset: str
65    matrix: str
66    filter_passes: List[FilterPassConfig]
67
68    def to_yml_format(self) -> Dict[str, Any]:
69        """Format data subset configuration to a yml compatible dictionary.
70
71        Returns:
72            a dictionary containing the dataset configuration.
73        """
74        yml_format = {KEY_DATASET: self.dataset, KEY_MATRIX: self.matrix}
75        # only include filter passes if it has entries
76        if len(self.filter_passes) > 0:
77            yml_format[KEY_DATA_SUBSET] = format_yml_config_list(self.filter_passes)
78
79        return yml_format
@dataclass
class FilterConfig(src.fairreckitlib.core.config.config_object.ObjectConfig):
24@dataclass
25class FilterConfig(ObjectConfig):
26    """Filter Configuration.
27
28    name: the name of the filter.
29    params: the parameters of the filter.
30    """

Filter Configuration.

name: the name of the filter. params: the parameters of the filter.

FilterConfig(name: str, params: Dict[str, Any])
@dataclass
class FilterPassConfig(src.fairreckitlib.core.config.config_yml.YmlConfig):
33@dataclass
34class FilterPassConfig(YmlConfig):
35    """Filter Pass Configuration.
36
37    The pass consists of multiple filters that are applied in order.
38
39    filters: list of filter configurations.
40    """
41
42    filters: List[FilterConfig]
43
44    def to_yml_format(self) -> Dict[str, Any]:
45        """Format filter pass configuration to a yml compatible dictionary.
46
47        Returns:
48            a dictionary containing the subgroup configuration.
49        """
50        return {KEY_DATA_FILTER_PASS: format_yml_config_list(self.filters)}

Filter Pass Configuration.

The pass consists of multiple filters that are applied in order.

filters: list of filter configurations.

FilterPassConfig( filters: List[src.fairreckitlib.data.filter.filter_config.FilterConfig])
def to_yml_format(self) -> Dict[str, Any]:
44    def to_yml_format(self) -> Dict[str, Any]:
45        """Format filter pass configuration to a yml compatible dictionary.
46
47        Returns:
48            a dictionary containing the subgroup configuration.
49        """
50        return {KEY_DATA_FILTER_PASS: format_yml_config_list(self.filters)}

Format filter pass configuration to a yml compatible dictionary.

Returns: a dictionary containing the subgroup configuration.

@dataclass
class DataSubsetConfig:
53@dataclass
54class DataSubsetConfig:
55    """Data Subset Configuration.
56
57    The subset of the data consists of multiple filter passes that are applied
58    on the dataset individually, and thereafter they are merged to create the subset.
59
60    dataset: the name of the dataset.
61    matrix: the name of the dataset matrix.
62    filter_passes: the subset as a list of filter passes.
63    """
64
65    dataset: str
66    matrix: str
67    filter_passes: List[FilterPassConfig]
68
69    def to_yml_format(self) -> Dict[str, Any]:
70        """Format data subset configuration to a yml compatible dictionary.
71
72        Returns:
73            a dictionary containing the dataset configuration.
74        """
75        yml_format = {KEY_DATASET: self.dataset, KEY_MATRIX: self.matrix}
76        # only include filter passes if it has entries
77        if len(self.filter_passes) > 0:
78            yml_format[KEY_DATA_SUBSET] = format_yml_config_list(self.filter_passes)
79
80        return yml_format

Data Subset Configuration.

The subset of the data consists of multiple filter passes that are applied on the dataset individually, and thereafter they are merged to create the subset.

dataset: the name of the dataset. matrix: the name of the dataset matrix. filter_passes: the subset as a list of filter passes.

DataSubsetConfig( dataset: str, matrix: str, filter_passes: List[src.fairreckitlib.data.filter.filter_config.FilterPassConfig])
def to_yml_format(self) -> Dict[str, Any]:
69    def to_yml_format(self) -> Dict[str, Any]:
70        """Format data subset configuration to a yml compatible dictionary.
71
72        Returns:
73            a dictionary containing the dataset configuration.
74        """
75        yml_format = {KEY_DATASET: self.dataset, KEY_MATRIX: self.matrix}
76        # only include filter passes if it has entries
77        if len(self.filter_passes) > 0:
78            yml_format[KEY_DATA_SUBSET] = format_yml_config_list(self.filter_passes)
79
80        return yml_format

Format data subset configuration to a yml compatible dictionary.

Returns: a dictionary containing the dataset configuration.