vantage6.algorithm.tools.decorators.data#
- data(number_of_databases=1)#
Decorator that adds algorithm data to a function
By adding @data() to a function, one or several pandas dataframes will be added to the front of the argument list. This data will be read from the databases that the user who creates the task provides.
Note that the user should provide exactly as many databases as the decorated function requires when they create the task.
There is one reserved argument mock_data in the function to be decorated. If this argument is provided, the decorator will add this mocked data to the front of the argument list, instead of reading in the data from the databases.
- Parameters:
number_of_databases (int) – Number of data sources to load. These will be loaded in order by which the user provided them. Default is 1.
- Returns:
Decorated function
- Return type:
callable
Examples
>>> @data(number_of_databases=2) >>> def my_algorithm(first_df: pd.DataFrame, second_df: pd.DataFrame, >>> <other arguments>): >>> pass