numpy在1.20版本就棄用了np.bool,需要使用bool或者np.bool_替代。
(以下為個人小實驗驗證,上面就已經(jīng)可以解決問題了)
以下是使用了1.20版本的numpy后出現(xiàn)的提示
?
?將1.20版本的numpy從np.bool改為 bool 或者 np.bool_ 如下,就沒有包warning
如果使用大于1.20版本的numpy然后使用np.bool
會報錯說numpy模塊沒有bool
此時也可以直接將代碼dtype=np.bool改為使用 dtype=blool 或者 dtype=np.bool_? 即可
dtype=bool
dtype=np.bool_
在Github上也有相關(guān)解釋文章來源:http://www.zghlxwxcb.cn/news/detail-564115.html
Update `np.bool` to be an alias to `np.bool_` and un-deprecate it · Issue #22021 · numpy/numpy (github.com)文章來源地址http://www.zghlxwxcb.cn/news/detail-564115.html
到了這里,關(guān)于解決numpy模塊沒有‘np.bool’的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!