<p dir="auto">It has to do with FP but I think it is still precarious considering a 'small' error changes the entire mesh.<br>
Following is an MWE</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt;np.mgrid[0.:0.5+0.5/2:0.5/2, 0.:0.2+0.2/2:0.2/2].reshape(2,-1).T
array([[ 0.  ,  0.  ],
       [ 0.  ,  0.1 ],
       [ 0.  ,  0.2 ],
       [ 0.  ,  0.3 ],
       [ 0.25,  0.  ],
       [ 0.25,  0.1 ],
       [ 0.25,  0.2 ],
       [ 0.25,  0.3 ],
       [ 0.5 ,  0.  ],
       [ 0.5 ,  0.1 ],
       [ 0.5 ,  0.2 ],
       [ 0.5 ,  0.3 ]])`"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt;np.mgrid[0.:0.5+0.5/2:0.5/2, 0.:0.2+0.2/2:0.2/2].reshape(2,-1).T
array([[ 0.  ,  0.  ],
       [ 0.  ,  0.1 ],
       [ 0.  ,  0.2 ],
       [ 0.  ,  0.3 ],
       [ 0.25,  0.  ],
       [ 0.25,  0.1 ],
       [ 0.25,  0.2 ],
       [ 0.25,  0.3 ],
       [ 0.5 ,  0.  ],
       [ 0.5 ,  0.1 ],
       [ 0.5 ,  0.2 ],
       [ 0.5 ,  0.3 ]])`
</code></pre></div>
<p dir="auto">which is due to the FP representation of <code class="notranslate">0.1+0.2</code></p>
<p dir="auto">However if I use the following, I get the expected result</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; np.mgrid[0.:0.75:0.25, 0.:0.3:0.1].reshape(2,-1).T
array([[ 0.  ,  0.  ],
       [ 0.  ,  0.1 ],
       [ 0.  ,  0.2 ],
       [ 0.25,  0.  ],
       [ 0.25,  0.1 ],
       [ 0.25,  0.2 ],
       [ 0.5 ,  0.  ],
       [ 0.5 ,  0.1 ],
       [ 0.5 ,  0.2 ]])`"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; np.mgrid[0.:0.75:0.25, 0.:0.3:0.1].reshape(2,-1).T
array([[ 0.  ,  0.  ],
       [ 0.  ,  0.1 ],
       [ 0.  ,  0.2 ],
       [ 0.25,  0.  ],
       [ 0.25,  0.1 ],
       [ 0.25,  0.2 ],
       [ 0.5 ,  0.  ],
       [ 0.5 ,  0.1 ],
       [ 0.5 ,  0.2 ]])`
</code></pre></div>
<p dir="auto">A silly workaround would be use only the first few (~16) decimal places for such cases but I do think that <code class="notranslate">float(format(0.1+0.2,'.16f'))</code> is not very natural to many people</p>
<p dir="auto">If I do <code class="notranslate">np.arange(3.18,3.21,0.01)</code>, it gives <code class="notranslate">array([ 3.18,  3.19,  3.2 ])</code>. However, if I do <code class="notranslate">np.arange(3.18,3.22,0.01)</code>, it gives <code class="notranslate">array([ 3.18,  3.19,  3.2 ,  3.21,  3.22])</code>. This seems inconsistent. Why is this so? I am using numpy 1.11.2 on Python 2.7.13.</p>