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

Scott Ransom sransom at nrao.edu
Tue Sep 19 13:51:16 CDT 2006


On Tuesday 19 September 2006 14:46, Travis Oliphant wrote:
> Sebastian Haase wrote:
> > 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 ?
>
> Hmm....  This is a problem.   There is a 'u' kind for unsigned
> integers.
>
> On my system I get 'u' when running the code you just gave.
>
> Can anybody on a 64-bit system confirm?

I'm on 64-bit Debian:

In [11]: arr=N.arange(10,dtype=N.uint)

In [12]: arr.dtype.kind
Out[12]: 'u'

In [13]: arr.dtype.itemsize
Out[13]: 4

In [14]: arr=N.arange(10,dtype=N.long)

In [15]: arr.dtype.kind
Out[15]: 'i'

In [16]: arr.dtype.itemsize
Out[16]: 8


Scott

-- 
Scott M. Ransom            Address:  NRAO
Phone:  (434) 296-0320               520 Edgemont Rd.
email:  sransom at nrao.edu             Charlottesville, VA 22903 USA
GPG Fingerprint: 06A9 9553 78BE 16DB 407B  FFCA 9BFA B6FF FFD3 2989




More information about the Numpy-discussion mailing list