[Numpy-discussion] Retrieving and flattening lower triangular components of inner axes of 3d array

2012-05-25 Thread Damien Moore
Hi List, I have an array, x, with dimensions (K,M,M). I would like to compute a new array, y ~ (K,M*(M+1)/2), such that y[k] = numpy.tril(x[k]).flatten() for each k = 0,..,K-1 Is there a way to do this without looping? I was trying with tril_indices but couldn't quite get the logic right. Thank

Re: [Numpy-discussion] numpy.genfromtxt converters issue

2010-11-08 Thread Damien Moore
Pierre GM gmail.com> writes: > On Nov 6, 2010, at 2:22 PM, Damien Moore wrote: > > > Hi List, > > > > I'm trying to import csv data as a numpy array using genfromtxt. > [...] > Please open a ticket so that I don't forget about it. T

Re: [Numpy-discussion] numpy.genfromtxt converters issue

2010-11-06 Thread Damien Moore
In reply to my own question, the trivial, but massively inefficient solution is: s=StringIO.StringIO('q1,2\nq3,4') a=numpy.genfromtxt(s,delimiter=',',converters={0:lambda s:float(s[1:])}) a1 = numpy.array(a.tolist()) But what I really want to do is have genfromtxt do the conversion for me. Specif

[Numpy-discussion] numpy.genfromtxt converters issue

2010-11-06 Thread Damien Moore
Hi List, I'm trying to import csv data as a numpy array using genfromtxt. The csv file contains mixed data, some floating point, others string codes and dates that I want to convert to floating point. The strange thing is that when I use the 'converters' argument to convert a subset of the columns

Re: [Numpy-discussion] combinatorial operations on a pair of arrays

2009-11-18 Thread Damien Moore
Emanuelle, perfect! thanks. > (assuming "import numpy as np", which is considered as a better practice > as "from numpy import *") actually I normally just "import numpy" but I guess np is nicer to type and read... cheers, Damien ___ NumPy-Discussion

Re: [Numpy-discussion] combinatorial operations on a pair of arrays

2009-11-18 Thread Damien Moore
ugh... I goofed. The code snippet should have read from numpy import * A=array([[1,2],[2,3],[3,4]]) B=array([[2,2],[3,3]]) C=zeros(A.shape) for i in xrange(len(A)): C[i]=(A[i]**B).sum(0) print C On Wed, Nov 18, 2009 at 2:17 PM, Damien Moore wrote: > The title of this e-mail is proba

[Numpy-discussion] combinatorial operations on a pair of arrays

2009-11-18 Thread Damien Moore
The title of this e-mail is probably misleading so let me just show some code: from numpy import * A=array([[1,2],[2,3],[3,4]]) B=array([[2,2],[3,3]]) C=zeros(A.shape) for i in xrange(len(A)): C[i]=sum(A[i]**B) print C What I want to do is eliminate the for loop and rely on numpy internals, but