Skip to content
Snippets Groups Projects
calculation_rules.py 1.36 KiB
Newer Older
File consists of several functions for the calculation rules of FAIR Quality KPIs
Richter, Manuela's avatar
Richter, Manuela committed
def test_function():
    """Test function to check module functionality"""
Richter, Manuela's avatar
Richter, Manuela committed
    print("You called the test function.")
    """
    Calculates the sum of one or more integers or lists.

    Args:
        *args: One or more integers or lists.

    Returns:
        total (int): The sum of all given integers and/or the sum
        of all items in all given lists.

    Raises:
        TypeError: If an argument with unsupported type is passed
            (i.e. anything other than int or list).
    """
    total = 0
    for arg in args:
        if isinstance(arg, int):  # Check if argument is an integer
            total += arg
        elif isinstance(arg, list):  # Check if argument is a list
            total += sum(arg)
        else:
            raise TypeError(
                f"Unsupported type {type(arg)} passed to kpi_sum()")
    return total

    # if arguments are handed over not as a list: sum(list(args))

# Add new functions for calculating some real complicated metrics
if __name__ == "__main__":
    """
    Function to inform that functions in this module is
    intended for import not usage as script
    """
        "This script contains functions for calculating the FAIR Quality KPIs."
        "It is not to be executed independently."