numpy difference between flat and ravel()
<p>What is the difference between the following?</p>

<pre><code>&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; arr = np.array([[[  0,   1,   2],
...                  [ 10,  12,  13]],
...                 [[100, 101, 102],
...                  [110, 112, 113]]])
&gt;&gt;&gt; arr
array([[[  0,   1,   2],
        [ 10,  12,  13]],
       [[100, 101, 102],
        [110, 112, 113]]])
&gt;&gt;&gt; arr.ravel()
array([  0,   1,   2,  10,  12,  13, 100, 101, 102, 110, 112, 113])
&gt;&gt;&gt; arr.ravel()[0] = -1
&gt;&gt;&gt; arr
array([[[ -1,   1,   2],
        [ 10,  12,  13]],
       [[100, 101, 102],
        [110, 112, 113]]])
&gt;&gt;&gt; list(arr.flat)
[-1, 1, 2, 10, 12, 13, 100, 101, 102, 110, 112, 113]
&gt;&gt;&gt; arr.flat[0] = 99
&gt;&gt;&gt; arr
array([[[ 99,   1,   2],
        [ 10,  12,  13]],
       [[100, 101, 102],
        [110, 112, 113]]])
</code></pre>

<p>Other than the fact that <code>flat</code> returns an iterator instead of a list, they appear to be the same, since they both alter the original array in place (this is in contrast to <code>flatten()</code>, which returns a copy of the array). So, is there any other significant difference between <code>flat</code> and <code>ravel()</code>? If not, when would it be useful to use one instead of the other?</p>