Re: [Numpy-discussion] numpy.array does not take generators

2007-08-17 Thread Timothy Hochberg
On 8/17/07, Barry Wark <[EMAIL PROTECTED]> wrote: > > Is there a reason not to add an argument to fromiter that specifies > the final size of the n-d array? Reading this discussion, I realized > that there are several places in my code where I create 2-D arrays > like this: > > arr = N.array([d.dat

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-17 Thread Barry Wark
Is there a reason not to add an argument to fromiter that specifies the final size of the n-d array? Reading this discussion, I realized that there are several places in my code where I create 2-D arrays like this: arr = N.array([d.data() for d in list_of_data_containers]), where d.data() returns

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-17 Thread Geoffrey Zhu
On 8/17/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Geoffrey Zhu wrote: > > Hi All, > > > > I want to construct a numpy array based on Python objects. In the > > below code, opts is a list of tuples. > > > > For example, > > > > opts=[ ('C', 100, 3, 'A'), ('K', 200, 5.4, 'B')] > > > > If I use a g

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-16 Thread Robert Kern
Geoffrey Zhu wrote: > Hi All, > > I want to construct a numpy array based on Python objects. In the > below code, opts is a list of tuples. > > For example, > > opts=[ ('C', 100, 3, 'A'), ('K', 200, 5.4, 'B')] > > If I use a generator like the following: > > K=numpy.array(o[2]/1000.0 for o in

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-16 Thread Alan G Isaac
On Thu, 16 Aug 2007, Geoffrey Zhu apparently wrote: > K=numpy.array(o[2]/1000.0 for o in opts) > It does not work. K=numpy.fromiter((o[2]/1000.0 for o in opts),'float') hth, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org ht

[Numpy-discussion] numpy.array does not take generators

2007-08-16 Thread Geoffrey Zhu
Hi All, I want to construct a numpy array based on Python objects. In the below code, opts is a list of tuples. For example, opts=[ ('C', 100, 3, 'A'), ('K', 200, 5.4, 'B')] If I use a generator like the following: K=numpy.array(o[2]/1000.0 for o in opts) It does not work. I have to use: nu