[Numpy-discussion] str/bytes object from arr.data?

2010-09-27 Thread Francesc Alted
Hi, Anybody knows a way to get a str object (bytes for Python = 2.6) out of a buffer object (i.e. the .data attribute of ndarrays) without copying data? I need this for avoid creating a new function that deals with buffer objects (instead of reusing the one for str/byte objects that I already

Re: [Numpy-discussion] str/bytes object from arr.data?

2010-09-27 Thread Zachary Pincus
As str objects are supposed to be immutable, I think anything official that makes a string from a numpy array is supposed to copy the data. But I think you can use ctypes to wrap a pointer and a length as a python string. Zach On Sep 27, 2010, at 8:28 AM, Francesc Alted wrote: Hi,

Re: [Numpy-discussion] Matlab IO Warning in mio5.py

2010-09-27 Thread Ralf Gommers
On Mon, Sep 27, 2010 at 12:07 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Sun, Sep 26, 2010 at 11:03 PM, Ben Longstaff longstaff2...@gmail.com wrote: Warning Message C:\Python26\lib\site-packages\scipy\io\matlab\mio5.py:90: RuntimeWarning: __builtin__.file size

Re: [Numpy-discussion] Asking for opinions: Priops

2010-09-27 Thread Dag Sverre Seljebotn
Friedrich Romstedt wrote: 2010/9/23 Dag Sverre Seljebotn da...@student.matnat.uio.no: Essentially, perhaps what you have sketched up + an ability to extend the graph with object conversion routes would be perfect for my own uses. So you can define a function with overloads (A, B) and (A,

Re: [Numpy-discussion] str/bytes object from arr.data?

2010-09-27 Thread Francesc Alted
A Monday 27 September 2010 15:04:14 Zachary Pincus escrigué: As str objects are supposed to be immutable, I think anything official that makes a string from a numpy array is supposed to copy the data. But I think you can use ctypes to wrap a pointer and a length as a python string. Yeah,

[Numpy-discussion] mean of empty sequence gives nan

2010-09-27 Thread Peter Butterworth
In numpy 1.5.0, I got the following for mean of an empty sequence (or array): In [21]: mean([]) Warning: invalid value encountered in double_scalars Out[21]: nan Is this behaviour expected ? Also, would it be possible to have more explicit warning messages about the problem being related numpy

Re: [Numpy-discussion] mean of empty sequence gives nan

2010-09-27 Thread Robert Kern
On Mon, Sep 27, 2010 at 17:51, Peter Butterworth butt...@gmail.com wrote: In numpy 1.5.0, I got the following for mean of an empty sequence (or array): In [21]: mean([]) Warning: invalid value encountered in double_scalars Out[21]: nan Is this behaviour expected ? np.sum([]) / len([]) -