On 29 Oct 2014 01:47, "Alexander Belopolsky" <ndar...@mac.com> wrote:
>
>
> On Tue, Oct 28, 2014 at 9:23 PM, Nathaniel Smith <n...@pobox.com> wrote:
>>
>> OTOH trying to make .flat into a full duck-compatible ndarray-like
>> type is a non-starter; it would take a tremendous amount of work for
>> no clear gain.
>
>
> I don't think so - I think all the heavy lifting is already done in
flatiter.  The missing parts are mostly trivial things like .size or .shape
or can be fudged by coercing to true ndarray using existing
flatiter.__array__ method.

Now try .resize()... The full ndarray api is vast, and niggling problems
would create endless maintenance issues. If your api is going to be that
leaky then it's better not to have it at all.

> It would be more interesting however if we could always return a true
ndarray view.  How is ndarray.diagonal() view implemented in 1.9?  Can
something similar be used to create a flat view?

.diagonal has no magic, it just turns out that the diagonal of any strided
array is also expressible as a strided array. (Specifically, new_strides =
(sum(old_strides),).) There is no analogous theorem for flattening.

-n
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to