我正在尝试用 python 为经济学论文建立一个模型并计算函数:
elif wage_online == max(wages):
# after going to online you get the highest wage after cost of education
learning_benefit = int(np.int((1 + gamma_online_learning) * x[0]) * exp(np.int(bivariate_distribution[x[0] - 1, x[1] - 1])))
social_benefit = int(((1 + gamma_online_social) * np.int(x[1])) * exp(np.int(bivariate_distribution[x[0] - 1, x[1] - 1])))
sigma_social.append(social_benefit)
sigma_learning.append(learning_benefit)
我收到以下错误
/Users/sa/Documents/Dissertation/first_defiation.py:160: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
learning_benefit = int(np.int((1 + gamma_online_learning) * x[0]) * exp(np.int(bivariate_distribution[x[0] - 1, x[1] - 1])))
我尝试通过将 exp 函数中的值包含为 np.int 来解决此问题,但无济于事。有谁知道警告来自哪个变量?
最佳答案
看起来您错过了方括号内需要 int
的地方:
social_benefit = (1 + gamma_online_social) * x[1] * exp(
bivariate_distribution[int(x[0] - 1), int(x[1] - 1)] # needed here for indexing
)
将来,您可以使用 warnings.filterwarnings('error')
来查找警告的准确回溯,这将指向您 __getitem__
关于python - Python 可见的弃用警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42866662/