[Numpy-discussion] integer array creation oddity

Suchindra Sandhu suchindra at gmail.com
Mon Jul 21 08:30:24 EDT 2008


Hi Stéfan,

Is that the recommended way of checking the type of the array? Ususally for
type checkin, I use the isinstance built-in in python, but I see that will
not work in this case. I must admit that I am a little confused by this. Why
is type different from dtype?

Thanks,
Suchindra


On Fri, Jul 18, 2008 at 7:10 PM, Stéfan van der Walt <stefan at sun.ac.za>
wrote:

> 2008/7/18 Suchindra Sandhu <suchindra at gmail.com>:
> > Can someone please explain to me this oddity?
> >
> > In [1]: import numpy as n
> >
> > In [8]: a = n.array((1,2,3), 'i')
> >
> > In [9]: type(a[0])
> > Out[9]: <type 'numpy.int32'>
>
> There's more than one int32 type lying around.  Rather, compare *dtypes*:
>
> In [19]: a.dtype == np.int32
> Out[19]: True
>
> Regards
> Stéfan
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080721/b78e0b48/attachment.html>


More information about the NumPy-Discussion mailing list