开发者

data type not understood

开发者 https://www.devze.com 2023-02-20 13:50 出处:网络
I\'m trying to use a matrix to compute stuff. The code is this imp开发者_运维技巧ort numpy as np

I'm trying to use a matrix to compute stuff. The code is this

imp开发者_运维技巧ort numpy as np
# some code
mmatrix = np.zeros(nrows, ncols)
print mmatrix[0, 0]

but I get 'data type not understood', and it works if I do it from terminal.


Try:

mmatrix = np.zeros((nrows, ncols))

Since the shape parameter has to be an int or sequence of ints

http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html

Otherwise you are passing ncols to np.zeros as the dtype.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号