2017-03-17 58 views
2

我試圖讓Python中的模型的經濟學論文,並在計算功能:可見棄用警告的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,但無濟於事。有誰知道警告來自哪個變量?

+0

我猜這個問題與'bivariate_distribution'的輸入有關。這是什麼包?需要什麼類型的輸入?什麼是'x'? – hpaulj

+0

爲每個涉及的變量檢查'type(variable_name)'。這將縮小這個問題的範圍。 –

回答

3

看起來你錯過了一個地方,需要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__

+0

這是正確的答案,我現在明白爲什麼,現在這麼明顯,我想這裏的索引 – entercaspa