Re: [Numpy-discussion] numpy.ascontiguousarray on byteswapped data !?
On Thursday 10 August 2006 21:32, Sebastian Haase wrote: Travis Oliphant wrote: Sebastian Haase wrote: Hi, Does numpy.ascontiguousarray(arr) fix the byteorder when arr is non-native byteorder ? If not, what functions does ? It can if you pass in a data-type with the right byteorder (or use a native built-in data-type). In NumPy, it's the data-type that carries the byte-order information.So, there are lot's of ways to fix the byte-order. So then the question is: what is the easiest way to say: give me the equivalent type of dtype, but with byteorder '' (or '=') !? I would be cumbersome (and ugly ;-) ) if one would have to manually assemble such a construct every time ... I just found this in myCVS/numpy/numpy/core/tests/test_numerictypes.py code def normalize_descr(descr): Normalize a description adding the platform byteorder. out = [] for item in descr: dtype = item[1] if isinstance(dtype, str): if dtype[0] not in ['|','','']: onebyte = dtype[1:] == 1 if onebyte or dtype[0] in ['S', 'V', 'b']: dtype = | + dtype else: dtype = byteorder + dtype if len(item) 2 and item[2] 1: nitem = (item[0], dtype, item[2]) else: nitem = (item[0], dtype) out.append(nitem) elif isinstance(item[1], list): l = [] for j in normalize_descr(item[1]): l.append(j) out.append((item[0], l)) else: raise ValueError(Expected a str or list and got %s % \ (type(item))) return out /code Is that what I was talking about !? It's quite a big animal. Would this be needed everytime I want to get a systembyte-ordered version of a given type !? - Sebastian Of course there is still the difference between fixing the byte-order and simply viewing the memory in the correct byte-order. The former physically flips bytes around, the latter just flips them on calculation and presentation. I understand. I need something that I can feed into my C routines that are to dumb to handle non-contiguous or byte-swapped data . - Sebastian - 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=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ascontiguousarray on byteswapped data !?
Sebastian Haase wrote: I just found this in myCVS/numpy/numpy/core/tests/test_numerictypes.py code def normalize_descr(descr): Normalize a description adding the platform byteorder. return out /code Is that what I was talking about !? It's quite a big animal. Would this be needed everytime I want to get a systembyte-ordered version of a given type !? No, I'm not even sure why exactly that was written but it's just in the testing code. I think the email I sent yesterday got lost because I sent it CC: numpy-discussion with no To: address. Here's what I said (more or less) in that email: You can use the .newbyteorder(endian='s') method of the dtype object to get a new data-type with a different byteorder. The possibilities for endian are 'swap', 'big' (''), 'little' (''), or 'native' ('='). This will descend down a complicated data-type and change all the byte-orders appropriately. Then you can use .astype(newtype) to convert to the new byteorder. The .isnative attribute of the data-type will tell you if the data-type (or all of it's fields in recent SVN) are in native byte-order. -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=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ascontiguousarray on byteswapped data !?
A Divendres 11 Agost 2006 22:02, Travis Oliphant va escriure: Sebastian Haase wrote: I just found this in myCVS/numpy/numpy/core/tests/test_numerictypes.py code def normalize_descr(descr): Normalize a description adding the platform byteorder. return out /code Is that what I was talking about !? It's quite a big animal. Would this be needed everytime I want to get a systembyte-ordered version of a given type !? No, I'm not even sure why exactly that was written but it's just in the testing code. I think this is my fault. Some months ago I contributed some testing code for checking numerical types, and ended with this 'animal'. Sorry about that ;-) Cheers! -- 0,0 Francesc Altet http://www.carabos.com/ V V Cárabos Coop. V. Enjoy Data - - 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=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] numpy.ascontiguousarray on byteswapped data !?
Hi, Does numpy.ascontiguousarray(arr) fix the byteorder when arr is non-native byteorder ? If not, what functions does ? - Sebastian Haase - 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=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ascontiguousarray on byteswapped data !?
Sebastian Haase wrote: Hi, Does numpy.ascontiguousarray(arr) fix the byteorder when arr is non-native byteorder ? If not, what functions does ? It can if you pass in a data-type with the right byteorder (or use a native built-in data-type). In NumPy, it's the data-type that carries the byte-order information.So, there are lot's of ways to fix the byte-order. Of course there is still the difference between fixing the byte-order and simply viewing the memory in the correct byte-order. The former physically flips bytes around, the latter just flips them on calculation and presentation. -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=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ascontiguousarray on byteswapped data !?
Travis Oliphant wrote: Sebastian Haase wrote: Hi, Does numpy.ascontiguousarray(arr) fix the byteorder when arr is non-native byteorder ? If not, what functions does ? It can if you pass in a data-type with the right byteorder (or use a native built-in data-type). In NumPy, it's the data-type that carries the byte-order information.So, there are lot's of ways to fix the byte-order. So then the question is: what is the easiest way to say: give me the equivalent type of dtype, but with byteorder '' (or '=') !? I would be cumbersome (and ugly ;-) ) if one would have to manually assemble such a construct every time ... Of course there is still the difference between fixing the byte-order and simply viewing the memory in the correct byte-order. The former physically flips bytes around, the latter just flips them on calculation and presentation. I understand. I need something that I can feed into my C routines that are to dumb to handle non-contiguous or byte-swapped data . - Sebastian - 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=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion