src.fairreckitlib.data.filter.filter_constants

This module contains filtering constants that are used in other modules.

Constants:

KEY_DATA_SUBSET: key that is used to identify a data subset.
KEY_DATA_FILTER_PASS: key that is used to identify a data filter pass.

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 filtering constants that are used in other modules.
 2
 3Constants:
 4
 5    KEY_DATA_SUBSET: key that is used to identify a data subset.
 6    KEY_DATA_FILTER_PASS: key that is used to identify a data filter pass.
 7
 8This program has been developed by students from the bachelor Computer Science at
 9Utrecht University within the Software Project course.
10© Copyright Utrecht University (Department of Information and Computing Sciences)
11"""
12
13from typing import Dict, Any
14
15
16FILTER_NUMERICAL = 'numerical'
17FILTER_CATEGORICAL = 'categorical'
18FILTER_COUNT = 'count'
19
20KEY_DATA_SUBSET = 'subset'
21KEY_DATA_FILTER_PASS = 'filter_pass'
22
23
24def deduce_filter_type(params: Dict[str, Any]) -> str:
25    """Get filter type ('numerical', 'categorical', 'count') from Configuration params.
26
27    Args:
28        params: Configuration parameters.
29
30    Return:
31        Either 'numerical', 'categorical' or 'count'. Default 'categorical'
32    """
33    keys = params.keys
34    if 'min' in keys and 'max' in keys:
35        return FILTER_NUMERICAL
36    if 'values' in keys:
37        return FILTER_CATEGORICAL
38    if 'threshold' in keys:
39        return FILTER_COUNT
40    return FILTER_CATEGORICAL
def deduce_filter_type(params: Dict[str, Any]) -> str:
25def deduce_filter_type(params: Dict[str, Any]) -> str:
26    """Get filter type ('numerical', 'categorical', 'count') from Configuration params.
27
28    Args:
29        params: Configuration parameters.
30
31    Return:
32        Either 'numerical', 'categorical' or 'count'. Default 'categorical'
33    """
34    keys = params.keys
35    if 'min' in keys and 'max' in keys:
36        return FILTER_NUMERICAL
37    if 'values' in keys:
38        return FILTER_CATEGORICAL
39    if 'threshold' in keys:
40        return FILTER_COUNT
41    return FILTER_CATEGORICAL

Get filter type ('numerical', 'categorical', 'count') from Configuration params.

Args: params: Configuration parameters.

Return: Either 'numerical', 'categorical' or 'count'. Default 'categorical'