I am confused with the difference between integer types.
For example, here is a numpy.array with dtype of np.int.
>>> arr_ = np.array([1,2], dtype = np.int)
Through the below code, it represents true that int is the same as np.int:
>>> int is np.int
Out[1]: True
However, when I select the first value of the array which is created with dtype of np.int, the below code outputs false.
>>> type(arr_[0]) is int
Out[2]: False
Why does the code output false, not true?
It seems like that dtype = np.int dose not applied on the arr_.
Why np.int dose not applied as a dtype on the array?
I've looked into this, but couldn't get what I need.
type(arr_[0])returns?numpy.int32, even I set a dtypenp.int.int(ornp.intwhich is another name for the same type) get converted tonp.int_when used as an array'sdtype. That explains the behavior you're seeing exactly. What more do you need to know?dtypeis usually not going to be the type object of elements retrieved from the array. After all, you can dodtype='int32', and the string'int32'can't betype(anything).type(arr_[0])