<p dir="auto">In NumPy 1.13, <code class="notranslate">numpy.diff()</code> no longer works with Bool-Arrays:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; np.diff([True, False, False])
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;.../lib/python3.6/site-packages/numpy/lib/function_base.py&quot;, line 1926
, in diff
    return a[slice1]-a[slice2]
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logi
cal_xor function instead."><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">diff</span>([<span class="pl-c1">True</span>, <span class="pl-c1">False</span>, <span class="pl-c1">False</span>])
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">"&lt;stdin&gt;"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
  <span class="pl-v">File</span> <span class="pl-s">".../lib/python3.6/site-packages/numpy/lib/function_base.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1926</span>
, <span class="pl-c1">in</span> <span class="pl-s1">diff</span>
    <span class="pl-k">return</span> <span class="pl-s1">a</span>[<span class="pl-s1">slice1</span>]<span class="pl-c1">-</span><span class="pl-s1">a</span>[<span class="pl-s1">slice2</span>]
<span class="pl-v">TypeError</span>: <span class="pl-s1">numpy</span> <span class="pl-s1">boolean</span> <span class="pl-s1">subtract</span>, <span class="pl-s1">the</span> <span class="pl-s">`-`</span> <span class="pl-s1">operator</span>, <span class="pl-s1">is</span> <span class="pl-s1">deprecated</span>, <span class="pl-s1">use</span> <span class="pl-s1">the</span> <span class="pl-s1">bitwise_xor</span>, <span class="pl-s1">the</span> <span class="pl-s">`^`</span> <span class="pl-s1">operator</span>, <span class="pl-s1">or</span> <span class="pl-s1">the</span> <span class="pl-s1">logi</span>
<span class="pl-s1">cal_xor</span> <span class="pl-s1">function</span> <span class="pl-s1">instead</span>.</pre></div>
<p dir="auto">It worked in NumPy 1.12.1 and the <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.diff.html" rel="nofollow">documentation says</a> that it should still work:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; np.diff([True, False, False])
array([ True, False], dtype=bool)"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">diff</span>([<span class="pl-c1">True</span>, <span class="pl-c1">False</span>, <span class="pl-c1">False</span>])
<span class="pl-en">array</span>([ <span class="pl-c1">True</span>, <span class="pl-c1">False</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">bool</span>)</pre></div>
<p dir="auto">Should modify the docstring accordingly, raise a meaningful error, or (preferably) make it work by hidding some logic under the hood.</p>
<p dir="auto">Traceback:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [11]: x = np.array([[True, True], [False, False]])

In [12]: np.diff(x)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-12-59225436601c&gt; in &lt;module&gt;()
----&gt; 1 np.diff(x)

/usr/lib/python3.6/site-packages/numpy/lib/function_base.py in diff(a, n, axis)
   1924         return diff(a[slice1]-a[slice2], n-1, axis=axis)
   1925     else:
-&gt; 1926         return a[slice1]-a[slice2]
   1927 
   1928 

TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.

In [13]: np.__version__
Out[13]: '1.13.0'"><pre class="notranslate"><code class="notranslate">In [11]: x = np.array([[True, True], [False, False]])

In [12]: np.diff(x)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-12-59225436601c&gt; in &lt;module&gt;()
----&gt; 1 np.diff(x)

/usr/lib/python3.6/site-packages/numpy/lib/function_base.py in diff(a, n, axis)
   1924         return diff(a[slice1]-a[slice2], n-1, axis=axis)
   1925     else:
-&gt; 1926         return a[slice1]-a[slice2]
   1927 
   1928 

TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.

In [13]: np.__version__
Out[13]: '1.13.0'
</code></pre></div>
<p dir="auto">xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="235471652" data-permission-text="Title is private" data-url="https://github.com/scikit-image/scikit-image/issues/2681" data-hovercard-type="issue" data-hovercard-url="/scikit-image/scikit-image/issues/2681/hovercard" href="https://github.com/scikit-image/scikit-image/issues/2681">scikit-image/scikit-image#2681</a></p>