[Numpy-discussion] arr.dtype.kind is 'i' for dtype=unit !?

Albert Strasheim fullung at gmail.com
Tue Sep 19 12:39:23 CDT 2006


Hello all

> -----Original Message-----
> From: numpy-discussion-bounces at lists.sourceforge.net [mailto:numpy-
> discussion-bounces at lists.sourceforge.net] On Behalf Of Sebastian Haase
> Sent: 19 September 2006 19:24
> To: Discussion of Numerical Python
> Subject: [Numpy-discussion] arr.dtype.kind is 'i' for dtype=unit !?
> 
> Hi,
> What are the possible values of
> arr.dtype.kind ?
> 
> It seems that signed and unsigned are considered to be the same "kind"
> >>> arr=N.arange(10,dtype=N.uint)
> >>> arr.dtype.kind
> 'i'
> >>> arr.dtype.itemsize
> 8
> (OK - this is just showing off our amd64 linux ;-) )
> 
> How can I distinguish signed from unsigned without having to list all
> possible
> cases explicitly ?

How about sctypes?

In [16]: numpy.sctypes.keys()
Out[17]: ['int', 'float', 'uint', 'complex', 'others']

So this should work:

sometype in numpy.sctypes['uint']
sometype in numpy.sctypes['int']

Cheers,

Albert





More information about the Numpy-discussion mailing list