<p dir="auto">Example</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: a = np.ones(10)[::2]  # flat iter will use updateifcopy for non-contiguous array

In [2]: a.flags
Out[2]: 
  C_CONTIGUOUS : False
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

In [3]: a.flat.__array__().flags
Out[3]: 
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : True

In [4]: a.flags
Out[4]: 
  C_CONTIGUOUS : False
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : False
  ALIGNED : True
  UPDATEIFCOPY : False"><pre class="notranslate"><code class="notranslate">In [1]: a = np.ones(10)[::2]  # flat iter will use updateifcopy for non-contiguous array

In [2]: a.flags
Out[2]: 
  C_CONTIGUOUS : False
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

In [3]: a.flat.__array__().flags
Out[3]: 
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : True

In [4]: a.flags
Out[4]: 
  C_CONTIGUOUS : False
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : False
  ALIGNED : True
  UPDATEIFCOPY : False
</code></pre></div>
<p dir="auto">What's going on here?</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; x = np.broadcast_to(1, (2,2))
&gt;&gt;&gt; x.flags.writeable = True  # ok, this is a little sketchy
&gt;&gt;&gt; x.flags.writeable
True
&gt;&gt;&gt; x.flat.__array__()
&gt;&gt;&gt; x.flags.writeable
False"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">broadcast_to</span>(<span class="pl-c1">1</span>, (<span class="pl-c1">2</span>,<span class="pl-c1">2</span>))
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-s1">flags</span>.<span class="pl-s1">writeable</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>  <span class="pl-c"># ok, this is a little sketchy</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-s1">flags</span>.<span class="pl-s1">writeable</span>
<span class="pl-c1">True</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-s1">flat</span>.<span class="pl-en">__array__</span>()
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-s1">flags</span>.<span class="pl-s1">writeable</span>
<span class="pl-c1">False</span></pre></div>