Skip to content
Snippets Groups Projects
Commit f0988ace authored by Hock, Martin's avatar Hock, Martin
Browse files

Docstrings, formatting. Rewrite of sum_kpi.

parent d805baa7
No related branches found
No related tags found
No related merge requests found
...@@ -4,20 +4,48 @@ File consists of several functions for the calculation rules of FAIR Quality KPI ...@@ -4,20 +4,48 @@ File consists of several functions for the calculation rules of FAIR Quality KPI
def test_function(): def test_function():
"""Test function to check module functionality"""
print("You called the test function.") print("You called the test function.")
# Function to calculate KPIS that use sums
# Or function to calculate the mass with sum?
def kpi_sum(*args): def kpi_sum(*args):
return sum(args[0]) """
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)) # if arguments are handed over not as a list: sum(list(args))
# KPI for calculating some real complicated metric
# Add new functions for calculating some real complicated metrics
if __name__ == "__main__": if __name__ == "__main__":
"""
Function to inform that functions in this module is
intended for import not usage as script
"""
print( print(
"This script contains functions for calculating the FAIR Quality KPIs. It is not to be executed independently." "This script contains functions for calculating the FAIR Quality KPIs."
"It is not to be executed independently."
) )
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment