From: Sebastian H. <ha...@ms...> - 2006-09-19 17:23:59
|
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 ? Thanks, Sebastian Haase |
From: Albert S. <fu...@gm...> - 2006-09-19 17:39:25
|
Hello all > -----Original Message----- > From: num...@li... [mailto:numpy- > dis...@li...] 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 |
From: Travis O. <oli...@ie...> - 2006-09-19 18:46:15
|
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? -Travis |
From: Scott R. <sr...@nr...> - 2006-09-19 18:51:51
|
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: sr...@nr... Charlottesville, VA 22903 USA GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989 |
From: Scott R. <sr...@nr...> - 2006-09-19 18:54:16
|
> > 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 Ack! That was on the wrong machine (32-bit Debian). Here is the 64-bit version: In [2]: arr=N.arange(10,dtype=N.uint) In [3]: arr.dtype.kind Out[3]: 'u' In [4]: arr.dtype.itemsize Out[4]: 8 In [5]: arr=N.arange(10,dtype=N.long) In [6]: arr.dtype.kind Out[6]: 'i' In [7]: arr.dtype.itemsize Out[7]: 8 Sorry about that, Scott -- Scott M. Ransom Address: NRAO Phone: (434) 296-0320 520 Edgemont Rd. email: sr...@nr... Charlottesville, VA 22903 USA GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989 |
From: Sebastian H. <ha...@ms...> - 2006-09-19 22:31:43
|
OK - I'm really sorry !! I also get 'u' -- I had a typo there ... But what is the complete list of kind values ? -Sebastian On Tuesday 19 September 2006 11:54, Scott Ransom wrote: > > > 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 > > Ack! That was on the wrong machine (32-bit Debian). Here is the 64-bit > version: > > In [2]: arr=N.arange(10,dtype=N.uint) > > In [3]: arr.dtype.kind > Out[3]: 'u' > > In [4]: arr.dtype.itemsize > Out[4]: 8 > > In [5]: arr=N.arange(10,dtype=N.long) > > In [6]: arr.dtype.kind > Out[6]: 'i' > > In [7]: arr.dtype.itemsize > Out[7]: 8 > > Sorry about that, > > Scott |
From: Matthew B. <mat...@gm...> - 2006-09-21 16:52:56
|
Hi, > It's in the array interface specification: > > http://numpy.scipy.org/array_interface.shtml I was interested in the 't' (bitfield) type - is there an example of usage somewhere? In [13]: dtype('t8') --------------------------------------------------------------------------- exceptions.TypeError Traceback (most recent call last) /home/mb312/python/<ipython console> TypeError: data type not understood Best, Matthew |
From: Travis O. <oli...@ie...> - 2006-09-21 16:59:24
|
Matthew Brett wrote: > Hi, > > >> It's in the array interface specification: >> >> http://numpy.scipy.org/array_interface.shtml >> > > I was interested in the 't' (bitfield) type - is there an example of > usage somewhere? > No, It's not implemented in NumPy. It's just part of the array interface specification for completeness. -Travis |
From: Travis O. <oli...@ee...> - 2006-09-19 22:44:50
|
Sebastian Haase wrote: >OK - I'm really sorry !! >I also get 'u' -- I had a typo there ... > >But what is the complete list of kind values ? > > It's in the array interface specification: http://numpy.scipy.org/array_interface.shtml -Travis |