Jonathan Taylor wrote:

> In some earlier code (at least one of) the following worked fine. I 
> just want
> to get a new type that is a byteswap of, say, float64 because I want to
> memmap an array with a non-native byte order.
>
> Any suggestions?

Last year the array scalars (like float64) were confused with the 
data-type objects dtype('=i4').  This was fortunately changed many 
months ago so the two are now separate concepts.  This may be why your 
old code worked.

You want to get a data-type object itself:

d = numpy.dtype(numpy.float64)
d = numpy.float64(1).dtype   # you have to instantiate a float64 object 
to access it's data-type.

Then

d.newbyteorder('>')  or d.newbyteorder('big') will work.

But, probably easier and clearer is just to use:

dlittle = numpy.dtype('<f8')
dbig = numpy.dtype('>f8')

There are now full-fledged data-type objects in NumPy.  These can be 
used everywhere old typecodes were used.  In fact, all other aliases get 
converted to these data-type objects because they are what NumPy needs 
to construct the ndarray.

These data-type objects are an important part of the basearray concept 
being introduced to Python, so education about them is very timely.  
They are an out-growth of the PyArray_Descr * structure that Numeric 
used to "represent" a data-type internally.   Basically , the old 
PyArray_Descr * structure was enhanced and given an Object header.  

Even just getting these data-type objects into Python would be a useful 
first-step to exchanging data.

For NumPy, the data-type objects have enabled very sophisticated 
data-type specification and are key to record-array support in NumPy. 


Best,

-Travis




Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to