Skip to content

period_names

List of names of the sub-daily periods/time intervals, sub-monthly periods/day types, and sub-yearly/seasons used in the Permanence Score components.

PeriodBase

Source code in multimno/core/constants/period_names.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class PeriodBase:
    @classmethod
    def is_valid_type(cls, value: str) -> bool:
        """
        Check if the given value is a valid type.

        Args:
            value: String to check

        Returns:
            bool: True if value is a valid type, False otherwise
        """
        return value in {
            getattr(cls, attr) for attr in dir(cls) if not attr.startswith("_") and isinstance(getattr(cls, attr), str)
        }

    @classmethod
    def values(cls) -> set[str]:
        """
        Get all string values defined in the class.

        Returns:
            set[str]: Set of all string values
        """
        return {
            getattr(cls, attr) for attr in dir(cls) if not attr.startswith("_") and isinstance(getattr(cls, attr), str)
        }

is_valid_type(value) classmethod

Check if the given value is a valid type.

Parameters:

Name Type Description Default
value str

String to check

required

Returns:

Name Type Description
bool bool

True if value is a valid type, False otherwise

Source code in multimno/core/constants/period_names.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@classmethod
def is_valid_type(cls, value: str) -> bool:
    """
    Check if the given value is a valid type.

    Args:
        value: String to check

    Returns:
        bool: True if value is a valid type, False otherwise
    """
    return value in {
        getattr(cls, attr) for attr in dir(cls) if not attr.startswith("_") and isinstance(getattr(cls, attr), str)
    }

values() classmethod

Get all string values defined in the class.

Returns:

Type Description
set[str]

set[str]: Set of all string values

Source code in multimno/core/constants/period_names.py
23
24
25
26
27
28
29
30
31
32
33
@classmethod
def values(cls) -> set[str]:
    """
    Get all string values defined in the class.

    Returns:
        set[str]: Set of all string values
    """
    return {
        getattr(cls, attr) for attr in dir(cls) if not attr.startswith("_") and isinstance(getattr(cls, attr), str)
    }

PeriodCombinations

All possible period combinations as flat lists.

Source code in multimno/core/constants/period_names.py
68
69
70
71
72
73
74
class PeriodCombinations:
    """All possible period combinations as flat lists."""

    # Basic combinations
    ALL_PERIODS = (Seasons.ALL, DayTypes.ALL, TimeIntervals.ALL)
    NIGHT_TIME_ALL = (Seasons.ALL, DayTypes.ALL, TimeIntervals.NIGHT_TIME)
    WORKING_HOURS_WORKDAYS = (Seasons.ALL, DayTypes.WORKDAYS, TimeIntervals.WORKING_HOURS)