Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Chris Barker
On Fri, Nov 4, 2016 at 10:36 AM, Nathaniel Smith wrote: > On Nov 4, 2016 10:32 AM, "Stephan Hoyer" wrote: > > fromiter dynamically resizes a NumPy array, like a Python list, except > with a growth factor of 1.5 > > Oh, right, and the dtype argument is mandatory, which is what makes this > poss

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Nathaniel Smith
On Nov 4, 2016 10:32 AM, "Stephan Hoyer" wrote: > > On Fri, Nov 4, 2016 at 10:24 AM, Nathaniel Smith wrote: >> >> Are you sure fromiter doesn't make an intermediate list or equivalent? It has to collect all the values before it can know the shape or dtype of the array to put them in. > > fromiter

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Stephan Hoyer
On Fri, Nov 4, 2016 at 10:24 AM, Nathaniel Smith wrote: > Are you sure fromiter doesn't make an intermediate list or equivalent? It > has to collect all the values before it can know the shape or dtype of the > array to put them in. > fromiter dynamically resizes a NumPy array, like a Python list

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Nathaniel Smith
Are you sure fromiter doesn't make an intermediate list or equivalent? It has to collect all the values before it can know the shape or dtype of the array to put them in. On Nov 4, 2016 5:26 AM, "Francesc Alted" wrote: 2016-11-04 13:06 GMT+01:00 Neal Becker : > I find I often write: > np.arra

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Robert Kern
On Fri, Nov 4, 2016 at 6:36 AM, Neal Becker wrote: > > Francesc Alted wrote: > > > 2016-11-04 13:06 GMT+01:00 Neal Becker : > > > >> I find I often write: > >> np.array ([some list comprehension]) > >> > >> mainly because list comprehensions are just so sweet. > >> > >> But I imagine this isn't pa

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Neal Becker
Francesc Alted wrote: > 2016-11-04 14:36 GMT+01:00 Neal Becker : > >> Francesc Alted wrote: >> >> > 2016-11-04 13:06 GMT+01:00 Neal Becker : >> > >> >> I find I often write: >> >> np.array ([some list comprehension]) >> >> >> >> mainly because list comprehensions are just so sweet. >> >> >> >> Bu

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Ryan May
On Fri, Nov 4, 2016 at 9:04 AM, Stephan Hoyer wrote: > On Fri, Nov 4, 2016 at 7:12 AM, Francesc Alted wrote: > >> Does this generalize to >1 dimensions? >>> >> >> A reshape() is not enough? What do you want to do exactly? >> > > np.fromiter takes scalar input and only builds a 1D array. So it a

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Daπid
On 4 November 2016 at 16:04, Stephan Hoyer wrote: > > But, we also don't have an unstack function. This would mostly be syntactic > sugar, but I think it would be a nice addition. Such a function actually > exists in TensorFlow: > https://g3doc.corp.google.com/third_party/tensorflow/g3doc/api_docs

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Stephan Hoyer
On Fri, Nov 4, 2016 at 7:12 AM, Francesc Alted wrote: > Does this generalize to >1 dimensions? >> > > A reshape() is not enough? What do you want to do exactly? > np.fromiter takes scalar input and only builds a 1D array. So it actually can't combine multiple values at once unless they are flat

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Francesc Alted
2016-11-04 14:36 GMT+01:00 Neal Becker : > Francesc Alted wrote: > > > 2016-11-04 13:06 GMT+01:00 Neal Becker : > > > >> I find I often write: > >> np.array ([some list comprehension]) > >> > >> mainly because list comprehensions are just so sweet. > >> > >> But I imagine this isn't particularly e

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Neal Becker
Francesc Alted wrote: > 2016-11-04 13:06 GMT+01:00 Neal Becker : > >> I find I often write: >> np.array ([some list comprehension]) >> >> mainly because list comprehensions are just so sweet. >> >> But I imagine this isn't particularly efficient. >> > > Right. Using a generator and np.fromiter(

Re: [Numpy-discussion] array comprehension

2016-11-04 Thread Francesc Alted
2016-11-04 13:06 GMT+01:00 Neal Becker : > I find I often write: > np.array ([some list comprehension]) > > mainly because list comprehensions are just so sweet. > > But I imagine this isn't particularly efficient. > Right. Using a generator and np.fromiter() will avoid the creation of the inter