a valid element not in np.arange, though print() does show it, dtypes are also same
<pre><code>a = 1.25
if a in np.arange(1,2,0.05):
    print(a)
</code></pre>

<p>but this if condition doesn't holds true,though</p>

<pre><code>print(np.arange(1,2,0.05))
[ 1.   1.05  1.1   1.15  1.2   1.25  1.3   1.35  1.4   1.45  1.5   1.55   1.6   1.65  1.7   1.75  1.8   1.85  1.9   1.95]
</code></pre>

<p>does have 1.25 in it.</p>

<p>I read that arange is not really consistent, but is there any workaround for this?</p>

<p>Using <code>item</code> to print values in full splendor:</p>

<pre><code>In [83]: for i in np.arange(1,2,0.05):print(i.item())
1.0
1.05
1.1
1.1500000000000001
1.2000000000000002
1.2500000000000002
1.3000000000000003
1.3500000000000003
1.4000000000000004
1.4500000000000004
1.5000000000000004
1.5500000000000005
1.6000000000000005
1.6500000000000006
1.7000000000000006
1.7500000000000007
1.8000000000000007
1.8500000000000008
1.9000000000000008
1.9500000000000008
</code></pre>

<p>Even <code>linspace</code> has those extra digits off at the end:</p>

<pre><code>In [84]: for i in np.linspace(1,2,21):print(i.item())
1.0
1.05
1.1
1.15
1.2
1.25
1.3
1.35
1.4
1.45
1.5
1.55
1.6
1.65
1.7000000000000002
1.75
1.8
1.85
1.9
1.9500000000000002
2.0
</code></pre>

<p><code>in</code> and <code>==</code> tests are not a good idea when working with floats.</p>

<p><code>isclose</code> and <code>allclose</code> test for small differences rather than exact match</p>

<pre><code>In [89]: np.isclose(np.arange(1,2,0.05),1.25)
Out[89]: 
array([False, False, False, False, False,  True, False, False, False,
       False, False, False, False, False, False, False, False, False,
       False, False], dtype=bool)
In [90]: np.isclose(np.arange(1,2,0.05),1.25).any()
Out[90]: True
</code></pre>

<p>Look at the <code>isclose</code> code to see all that is involved in comparing floats.</p>

python numpy