<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 23, 2013 at 10:46 AM, Pauli Virtanen <span dir="ltr"><<a href="mailto:pav@iki.fi" target="_blank">pav@iki.fi</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

23.07.2013 17:34, Benjamin Root kirjoitti:<br>
[clip]<br>
> Don't assume .flat is not commonly used.  A common idiom in matlab is<br>
> "a[:]" to flatten an array. When porting code over from matlab, it is<br>
> typical to replace that with either "a.flat" or "a.flatten()", depending<br>
> on whether an iterator or an array is needed.<br>
<br>
It is much more rarely used than `ravel()` and `flatten()`, as can be<br>
verified by grepping e.g. the matplotlib source code.<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>The matplotlib source code is not a port from Matlab, so grepping that wouldn't prove anything.<br><br>Meanwhile, the "NumPy for Matlab users" page notes that a.flatten() makes a copy. A newbie to NumPy would then (correctly) look up the documentation for a.flatten() and see in the "See Also" section that "a.flat" is just an iterator rather than a copy, and would often use that to avoid the copy.<br>

<br></div><div>Cheers!<br>Ben Root<br></div></div></div></div>