[Numpy-discussion] array comprehension

Ryan May rmay31 at gmail.com
Fri Nov 4 11:33:22 EDT 2016


On Fri, Nov 4, 2016 at 9:04 AM, Stephan Hoyer <shoyer at gmail.com> wrote:

> On Fri, Nov 4, 2016 at 7:12 AM, Francesc Alted <faltet at gmail.com> 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 flattened out in
> Python. It could be nice to add support for non-scalar inputs, stacking
> them similarly to np.array. Likewise, it could be nice to add an axis
> argument, so it can work similarly to np.stack.
>

 itertools.product, itertools.permutation, etc. with np.fromiter (and
reshape) is probably also useful here, though it doesn't solve the
non-scalar problem.

Ryan

-- 
Ryan May
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20161104/9a13d8ce/attachment.html>


More information about the NumPy-Discussion mailing list