def test_logarithmic_utility(): """Calculate the logarithmic utility and checks that it is not none..""" utility_params = {"good_id": 20.0} exchange_params = {"FET": 10.0} good_holdings = {"good_id": 2} preferences = Preferences() preferences.set( utility_params_by_good_id=utility_params, exchange_params_by_currency_id=exchange_params, ) log_utility = preferences.logarithmic_utility(quantities_by_good_id=good_holdings) assert log_utility is not None, "Log_utility must not be none."
def test_utility(): """Calculate the score.""" utility_params = {"good_id": 20.0} exchange_params = {"FET": 10.0} currency_holdings = {"FET": 100} good_holdings = {"good_id": 2} preferences = Preferences() preferences.set( utility_params_by_good_id=utility_params, exchange_params_by_currency_id=exchange_params, ) score = preferences.utility( quantities_by_good_id=good_holdings, amount_by_currency_id=currency_holdings, ) linear_utility = preferences.linear_utility(amount_by_currency_id=currency_holdings) log_utility = preferences.logarithmic_utility(quantities_by_good_id=good_holdings) assert ( score == log_utility + linear_utility ), "The score must be equal to the sum of log_utility and linear_utility."