<p dir="auto">The line (</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/numpy/numpy/blob/843792b6d349133114930911424772e6bbbc0c9c/numpy/core/numeric.py#L2157">numpy/numpy/core/numeric.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 2157
      in
      <a data-pjax="true" class="commit-tease-sha" href="/numpy/numpy/commit/843792b6d349133114930911424772e6bbbc0c9c">843792b</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L2157" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="2157"></td>
          <td id="LC2157" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-en">all</span>(<span class="pl-en">less_equal</span>(<span class="pl-en">abs</span>(<span class="pl-s1">x</span><span class="pl-c1">-</span><span class="pl-s1">y</span>), <span class="pl-s1">atol</span> <span class="pl-c1">+</span> <span class="pl-s1">rtol</span> <span class="pl-c1">*</span> <span class="pl-en">abs</span>(<span class="pl-s1">y</span>))) </td>
        </tr>
    </tbody></table>
  </div>
</div>
):<p></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="r = all(less_equal(abs(x-y), atol + rtol * abs(y)))"><pre class="notranslate"><code class="notranslate">r = all(less_equal(abs(x-y), atol + rtol * abs(y)))
</code></pre></div>
<p dir="auto">abs(y) can be negative if y contains the smallest negative integer.</p>
<p dir="auto">The following demonstrates the problem:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; a=np.int32(-2147483648) 
&gt;&gt;&gt; a
-2147483648
&gt;&gt;&gt; a==a
True
&gt;&gt;&gt; abs(a)
-2147483648
&gt;&gt;&gt; np.allclose(a, a)
False"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; a=np.int32(-2147483648) 
&gt;&gt;&gt; a
-2147483648
&gt;&gt;&gt; a==a
True
&gt;&gt;&gt; abs(a)
-2147483648
&gt;&gt;&gt; np.allclose(a, a)
False
</code></pre></div>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1684" rel="nofollow">http://projects.scipy.org/numpy/ticket/1684</a> on 2010-11-22 by trac user lamblin, assigned to unknown.</em></p>
<p dir="auto">If I create an array containing the minimal value of an int dtype, for instance an 'int8' array containing -128, numpy.allclose fails to detect it is "close" to itself, although it is equal.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; a = numpy.asarray(-128, dtype='int8')
&gt;&gt;&gt; numpy.all(a == a)
True
&gt;&gt;&gt; numpy.allclose(a, a)
False"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; a = numpy.asarray(-128, dtype='int8')
&gt;&gt;&gt; numpy.all(a == a)
True
&gt;&gt;&gt; numpy.allclose(a, a)
False
</code></pre></div>
<p dir="auto">I would expect:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; numpy.allclose(a, a)
True"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; numpy.allclose(a, a)
True
</code></pre></div>
<p dir="auto">This is due to the fact that the tolerance uses numpy.absolute, and in that case, it is negative:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; numpy.absolute(a)
array([-128], dtype=int8)"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; numpy.absolute(a)
array([-128], dtype=int8)
</code></pre></div>
<p dir="auto">I reproduced the same with int16 and -2<strong>15, int32 and -2</strong>31, and int64 and -2**63.</p>