From: Francesc A. <fa...@ca...> - 2006-09-27 07:49:04
|
Hello, Sorry for being insistent, but I recognize that I'm having a bad time with NumPy data type rational. Is there an explanation for this?: >>> numpy.dtype('i4').type <type 'numpy.int32'> >>> numpy.dtype('int32').type <type 'numpy.int32'> >>> numpy.dtype('i4').type =3D=3D numpy.dtype('int32').type True So far so good, but is the next the intended behaviour? >>> numpy.typeDict['i4'] <type 'numpy.int32'> >>> numpy.typeDict['int32'] <type 'numpy.int32'> >>> numpy.typeDict['i4'] =3D=3D numpy.typeDict['int32'] False --=20 >0,0< Francesc Altet http://www.carabos.com/ V V C=C3=A1rabos Coop. V. Enjoy Data "-" |
From: James G. <jg...@ca...> - 2006-09-27 09:01:24
|
Francesc Altet wrote: > So far so good, but is the next the intended behaviour? > >>>> numpy.typeDict['i4'] > <type 'numpy.int32'> >>>> numpy.typeDict['int32'] > <type 'numpy.int32'> >>>> numpy.typeDict['i4'] == numpy.typeDict['int32'] > False > > By way of comparison, I get (Linux/AMD 64): In [1]: import numpy In [2]: numpy.typeDict['i4'] == numpy.typeDict['int32'] Out[2]: True In [3]: numpy.typeDict['i4'] is numpy.typeDict['int32'] Out[3]: True In [4]: numpy.__version__ Out[4]: '1.0b5' -- "Eternity's a terrible thought. I mean, where's it all going to end?" -- Tom Stoppard, Rosencrantz and Guildenstern are Dead |
From: Francesc A. <fa...@ca...> - 2006-09-27 11:22:46
|
El dc 27 de 09 del 2006 a les 10:01 +0100, en/na James Graham va escriure: > Francesc Altet wrote: > > So far so good, but is the next the intended behaviour? > >=20 > >>>> numpy.typeDict['i4'] > > <type 'numpy.int32'> > >>>> numpy.typeDict['int32'] > > <type 'numpy.int32'> > >>>> numpy.typeDict['i4'] =3D=3D numpy.typeDict['int32'] > > False > >=20 > >=20 > By way of comparison, I get (Linux/AMD 64): >=20 > In [1]: import numpy >=20 > In [2]: numpy.typeDict['i4'] =3D=3D numpy.typeDict['int32'] > Out[2]: True >=20 > In [3]: numpy.typeDict['i4'] is numpy.typeDict['int32'] > Out[3]: True >=20 > In [4]: numpy.__version__ > Out[4]: '1.0b5' Yeah, but I'm on Linux/AMD32. I'd bet that in your machine you will get something like: In [2]: numpy.typeDict['i8'] =3D=3D numpy.typeDict['int64'] Out[2]: False --=20 >0,0< Francesc Altet http://www.carabos.com/ V V C=C3=A1rabos Coop. V. Enjoy Data "-" |
From: Travis O. <oli...@ie...> - 2006-09-27 16:35:28
|
Francesc Altet wrote: > Hello, > > Sorry for being insistent, but I recognize that I'm having a bad time > with NumPy data type rational. Is there an explanation for this?: > > >>>> numpy.dtype('i4').type >>>> > <type 'numpy.int32'> > >>>> numpy.dtype('int32').type >>>> > <type 'numpy.int32'> > >>>> numpy.dtype('i4').type == numpy.dtype('int32').type >>>> > True > > So far so good, but is the next the intended behaviour? > > >>>> numpy.typeDict['i4'] >>>> > <type 'numpy.int32'> > >>>> numpy.typeDict['int32'] >>>> > <type 'numpy.int32'> > >>>> numpy.typeDict['i4'] == numpy.typeDict['int32'] >>>> No, this isn't correct behavior. This time you've caught an actual problem :-) The typeDict (actually the sctypeDict --- scalar-type-dictionary returns a scalar type given a string not a data-type object) is only used if no other conversion can be found for the object. It used to be much more useful before the data-type objects were formalized last year. -Travis |
From: Travis O. <oli...@ie...> - 2006-09-27 17:01:19
|
Francesc Altet wrote: > Hello, > > Sorry for being insistent, but I recognize that I'm having a bad time > with NumPy data type rational. Is there an explanation for this?: > > Your actually talking about the array scalar types not the data-type objects. But, more to the point.... >>>> numpy.typeDict['i4'] >>>> > <type 'numpy.int32'> > >>>> numpy.typeDict['int32'] >>>> > <type 'numpy.int32'> > >>>> numpy.typeDict['i4'] == numpy.typeDict['int32'] >>>> > False > > On my 32-bit system I get: numpy.sctypeDict['i4'] is numpy.sctypeDict['int32'] True Hmm..... I don't know why you are getting a different result, but perhaps it has to do with the fact that the character alias ('i4') is not getting set at the same type as 'int32'. I just fixed that. That should fix the problem. -travis |
From: Francesc A. <fa...@ca...> - 2006-09-27 17:29:32
|
El dc 27 de 09 del 2006 a les 11:01 -0600, en/na Travis Oliphant va escriure: > Francesc Altet wrote: > > Hello, > > > > Sorry for being insistent, but I recognize that I'm having a bad time > > with NumPy data type rational. Is there an explanation for this?: > > > > =20 > Your actually talking about the array scalar types not the data-type=20 > objects.=20 Yes, that's right. It's just that I didn't get used to the correct jargon :-( > On my 32-bit system I get: >=20 > numpy.sctypeDict['i4'] is numpy.sctypeDict['int32'] >=20 > True >=20 >=20 > Hmm..... I don't know why you are getting a different result, but=20 > perhaps it has to do with the fact that the character alias ('i4') is=20 > not getting set at the same type as 'int32'. I just fixed that. That=20 > should fix the problem. Yup. I can confirm that the problem is solved in my machine as well. Thanks! --=20 >0,0< Francesc Altet http://www.carabos.com/ V V C=C3=A1rabos Coop. V. Enjoy Data "-" |