On Mon, Jul 21, 2008 at 3:37 PM, Stéfan van der Walt email@example.com wrote:
2008/7/21 Suchindra Sandhu firstname.lastname@example.org:
Is that the recommended way of checking the type of the array? Ususally
type checkin, I use the isinstance built-in in python, but I see that
not work in this case. I must admit that I am a little confused by this.
is type different from dtype?
Data-types contain additional information needed to lay out numerical types in memory, such as byte-order and bit-width. Each data-type has an associated Python type, which tells you the type of scalars in an array of that dtype. For example, here are two NumPy data-types that are not equal:
In : d1 = np.dtype(int).newbyteorder('>') In : d2 = np.dtype(int).newbyteorder('<')
In : d1.type Out: <type 'numpy.int32'>
In : d2.type Out: <type 'numpy.int32'>
In : d1 == d2 Out: False
I don't know why there is more than one int32 type (I would guess it has something to do with the way types are detected upon build; maybe Robert or Travis could tell you more).
They correspond to two C types of the same size, int and long. On 64 bit systems you should have two int64 types, long and longlong.
In : dtype('i').name Out: 'int32'
In : dtype('l').name Out: 'int32'