[Numpy-discussion] dtype and dtype.char

Charles سمير Doutriaux doutriaux1 at llnl.gov
Tue Sep 8 16:13:45 EDT 2009


Hi Robert,

Ok we have a section of code that used to be like that:

   char t;
   switch(type) {
   case NPY_CHAR:
     t = 'c';
     break;
etc...

I now replaced with
   char t;
   switch(type) {
   case NPY_CHAR:
     t = NPY_CHARLTR;
     break;

But I'm still stuck with numpy.uint64
NPY_UINT64LTR does not seem to exist....

What do you recommend?

C.

On Sep 8, 2009, at 1:02 PM, Robert Kern wrote:

> 2009/9/8 Charles سمير Doutriaux <doutriaux1 at llnl.gov>:
>> Hi,
>>
>> I'm testing our code on 64bit vs 32bit
>>
>> I just realized that the dtype.car is platform dependent.
>>
>> I guess it's normal
>>
>> her emy little test:
>> for t in
>> [numpy
>> .byte
>> ,numpy
>> .short
>> ,numpy
>> .int
>> ,numpy
>> .int32
>> ,numpy
>> .float
>> ,numpy
>> .float32
>> ,numpy
>> .double
>> ,numpy.ubyte,numpy.ushort,numpy.uint,numpy.int64,numpy.uint64]:
>>     print 'Testing type:',t
>>     data = numpy.array([0], dtype=t)
>>     print data.dtype.char,data.dtype
>>
>>
>> On 64bit I get for numpy.unit64:
>> Testing type: <type 'numpy.uint64'>
>> L uint64
>>
>> Whereas on 32bit i get
>> Testing type: <type 'numpy.uint64'>
>> Q uint64
>>
>> Is it really normal? I guess that means I shouldn't expect the
>> dtype.char to be the same on all platform....
>>
>> Is that right?
>
> Yes. dtype.char corresponds more closely to the C type ("L" ==
> "unsigned long" and "Q" == "unsigned long long") which is platform
> specific.
>
> -- 
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://*mail.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list