[Numpy-discussion] Why ndarray provides four ways to flatten?
sebastian at sipsolutions.net
Wed Oct 29 05:16:51 EDT 2014
On Di, 2014-10-28 at 14:03 -0400, Alan G Isaac wrote:
> On 10/28/2014 1:42 PM, Stephan Hoyer wrote:
> > np.nditer is a reasonable alternative to .flat (and it's documented as such), but it's a rather inelegant, kitchen-sink type function.
> I'm not sure what "reasonable" means here,
> other than "in principle, possible to use".
> In particular, `flat` is much more elegant,
> and includes an automatic guarantee that the
> iterations will be in C-contiguous style.
I don't really like flat (it is a pretty old part of numpy), but I
agree, while you can force nditer to be C-contiguous, nditer has its own
problems and is also pretty complex. I would argue that nditer it is a
"you know what you are doing" type of function... Or of course if you
want to understand the C-Api.
Unless you keep in mind how buffers are copied around inside it, using
half its features is dangerous.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: This is a digitally signed message part
More information about the NumPy-Discussion