Hi all,

I didn't get any answers to this email. Is it because the proposed
addition to numpy is not of any interest to anybody apart from me ?
Maybe the way I introduced this is wrong. Please tell me what is wrong
with this proposition.

Regards,

Gaël

On Fri, Oct 20, 2006 at 01:28:52PM +0200, Gael Varoquaux wrote:
> Hi,

> There is an operation I do a lot, I would call it "unrolling" a array.
> The best way to describe it is probably to give the code:

> def unroll(M):
>     """ Flattens the array M and returns a 2D array with the first columns 
>       being the indices of M, and the last column the flatten M.
>     """
>     return hstack((indices(M.shape).reshape(-1,M.ndim),M.reshape(-1,1)))

> Example:

> >>> M
> array([[ 0.73530097,  0.3553424 ,  0.3719772 ],
>        [ 0.83353373,  0.74622133,  0.14748905],
>        [ 0.72023762,  0.32306969,  0.19142366]])

> >>> unroll(M)
> array([[ 0.        ,  0.        ,  0.73530097],
>        [ 0.        ,  1.        ,  0.3553424 ],
>        [ 1.        ,  1.        ,  0.3719772 ],
>        [ 2.        ,  2.        ,  0.83353373],
>        [ 2.        ,  0.        ,  0.74622133],
>        [ 1.        ,  2.        ,  0.14748905],
>        [ 0.        ,  1.        ,  0.72023762],
>        [ 2.        ,  0.        ,  0.32306969],
>        [ 1.        ,  2.        ,  0.19142366]])


> The docstring sucks. The function is trivial (when you know numpy a bit).
> Maybe this function already exists in numpy, if so I couldn't find it.
> Elsewhere I propose it for inclusion.

> Cheers,

> Gaël

> -------------------------------------------------------------------------
> 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
> Numpy-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion

-------------------------------------------------------------------------
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
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to