<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Python 3.7.6 (default, Jan 30 2020, 09:44:41) 
[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; np.__version__
'1.17.0'
&gt;&gt;&gt; np.lexsort(np.empty((0, 2), dtype=int).T)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;&lt;__array_function__ internals&gt;&quot;, line 6, in lexsort
MemoryError
&gt;&gt;&gt; "><pre class="notranslate"><span class="pl-v">Python</span> <span class="pl-c1">3.7</span><span class="pl-c1">.6</span> (<span class="pl-s1">default</span>, <span class="pl-v">Jan</span> <span class="pl-c1">30</span> <span class="pl-c1">2020</span>, <span class="pl-c1">09</span>:<span class="pl-c1">44</span>:<span class="pl-c1">41</span>) 
[<span class="pl-v">GCC</span> <span class="pl-c1">9.2</span><span class="pl-c1">.1</span> <span class="pl-c1">20190827</span> (<span class="pl-v">Red</span> <span class="pl-v">Hat</span> <span class="pl-c1">9.2</span><span class="pl-c1">.1</span><span class="pl-c1">-</span><span class="pl-c1">1</span>)] <span class="pl-s1">on</span> <span class="pl-s1">linux</span>
<span class="pl-v">Type</span> <span class="pl-s">"help"</span>, <span class="pl-s">"copyright"</span>, <span class="pl-s">"credits"</span> <span class="pl-c1">or</span> <span class="pl-s">"license"</span> <span class="pl-k">for</span> <span class="pl-s1">more</span> <span class="pl-s1">information</span>.
<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-s1">__version__</span>
'<span class="pl-c1">1.17</span>.<span class="pl-c1">0</span>'
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">lexsort</span>(<span class="pl-s1">np</span>.<span class="pl-en">empty</span>((<span class="pl-c1">0</span>, <span class="pl-c1">2</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">int</span>).<span class="pl-v">T</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-c1">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">"&lt;__array_function__ internals&gt;"</span>, <span class="pl-s1">line</span> <span class="pl-c1">6</span>, <span class="pl-c1">in</span> <span class="pl-s1">lexsort</span>
<span class="pl-v">MemoryError</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> </pre></div>
<p dir="auto">Numpy 1.17.0 raises MemoryError when using <code class="notranslate">lexsort</code> on an empty array with non-standard <code class="notranslate">strides</code>. If <code class="notranslate">strides</code> is the natural one, or if there is &gt;= 1 element in the input, then it works as expected.</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np

xs = np.array([], dtype='i8')
assert xs.strides == (8,)
assert np.lexsort((xs,)).shape[0] == 0 # Works

ys = np.array([0], dtype='i8')
ys.strides = (16,)
assert np.lexsort((ys,)).shape[0] == 1 # Works

xs.strides = (16,)
assert np.lexsort((xs,)).shape[0] == 0 # MemoryError"><pre class="notranslate"><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-s1">xs</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'i8'</span>)
<span class="pl-k">assert</span> <span class="pl-s1">xs</span>.<span class="pl-s1">strides</span> <span class="pl-c1">==</span> (<span class="pl-c1">8</span>,)
<span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">lexsort</span>((<span class="pl-s1">xs</span>,)).<span class="pl-s1">shape</span>[<span class="pl-c1">0</span>] <span class="pl-c1">==</span> <span class="pl-c1">0</span> <span class="pl-c"># Works</span>

<span class="pl-s1">ys</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">0</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'i8'</span>)
<span class="pl-s1">ys</span>.<span class="pl-s1">strides</span> <span class="pl-c1">=</span> (<span class="pl-c1">16</span>,)
<span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">lexsort</span>((<span class="pl-s1">ys</span>,)).<span class="pl-s1">shape</span>[<span class="pl-c1">0</span>] <span class="pl-c1">==</span> <span class="pl-c1">1</span> <span class="pl-c"># Works</span>

<span class="pl-s1">xs</span>.<span class="pl-s1">strides</span> <span class="pl-c1">=</span> (<span class="pl-c1">16</span>,)
<span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">lexsort</span>((<span class="pl-s1">xs</span>,)).<span class="pl-s1">shape</span>[<span class="pl-c1">0</span>] <span class="pl-c1">==</span> <span class="pl-c1">0</span> <span class="pl-c"># MemoryError</span></pre></div>
<h3 dir="auto">Numpy/Python version information:</h3>
<p dir="auto">1.17.0 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)]</p>