<p dir="auto">The following code produces a segmentation fault in my configuration:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="np.bincount(np.ones(np.power(2,32),dtype=(np.uint16)))"><pre class="notranslate"><span class="pl-s1">np</span>.<span class="pl-en">bincount</span>(<span class="pl-s1">np</span>.<span class="pl-en">ones</span>(<span class="pl-s1">np</span>.<span class="pl-en">power</span>(<span class="pl-c1">2</span>,<span class="pl-c1">32</span>),<span class="pl-s1">dtype</span><span class="pl-c1">=</span>(<span class="pl-s1">np</span>.<span class="pl-s1">uint16</span>)))</pre></div>
<p dir="auto">platform : linux-64<br>
numpy version: 1.93</p>
<p dir="auto">I'm getting this weird concatenating issue when trying to transform a numpy array. When I filter by the 2nd column of the array, I get correct results, but when I filter by the third, the dtype is changed to U1, and the text is truncated.</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

dat = np.array([[2.017298e+06, 7.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00], 
                [2.017299e+06, 7.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00], 
                [2.017199e+06, 0.000000e+00, 2.000000e+02, 0.000000e+00, 0.000000e+00], 
                [2.017135e+06, 0.000000e+00, 7.000000e+01, 1.000000e+01, 4.000000e+00]])

resA = np.apply_along_axis( (lambda a : &quot;foo&quot; if (a[1] != 0) else &quot;&quot; ), 1, dat)

resB = np.apply_along_axis( (lambda a : &quot;foo&quot; if (a[2] != 0) else &quot;&quot; ), 1, dat)

print(&quot;Res A&quot;)
print(resA)
print(&quot;Res B&quot;)
print(resB)"><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">dat</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([[<span class="pl-c1">2.017298e+06</span>, <span class="pl-c1">7.000000e+00</span>, <span class="pl-c1">0.000000e+00</span>, <span class="pl-c1">0.000000e+00</span>, <span class="pl-c1">0.000000e+00</span>], 
                [<span class="pl-c1">2.017299e+06</span>, <span class="pl-c1">7.000000e+00</span>, <span class="pl-c1">0.000000e+00</span>, <span class="pl-c1">0.000000e+00</span>, <span class="pl-c1">0.000000e+00</span>], 
                [<span class="pl-c1">2.017199e+06</span>, <span class="pl-c1">0.000000e+00</span>, <span class="pl-c1">2.000000e+02</span>, <span class="pl-c1">0.000000e+00</span>, <span class="pl-c1">0.000000e+00</span>], 
                [<span class="pl-c1">2.017135e+06</span>, <span class="pl-c1">0.000000e+00</span>, <span class="pl-c1">7.000000e+01</span>, <span class="pl-c1">1.000000e+01</span>, <span class="pl-c1">4.000000e+00</span>]])

<span class="pl-s1">resA</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">apply_along_axis</span>( (<span class="pl-k">lambda</span> <span class="pl-s1">a</span> : <span class="pl-s">"foo"</span> <span class="pl-k">if</span> (<span class="pl-s1">a</span>[<span class="pl-c1">1</span>] <span class="pl-c1">!=</span> <span class="pl-c1">0</span>) <span class="pl-k">else</span> <span class="pl-s">""</span> ), <span class="pl-c1">1</span>, <span class="pl-s1">dat</span>)

<span class="pl-s1">resB</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">apply_along_axis</span>( (<span class="pl-k">lambda</span> <span class="pl-s1">a</span> : <span class="pl-s">"foo"</span> <span class="pl-k">if</span> (<span class="pl-s1">a</span>[<span class="pl-c1">2</span>] <span class="pl-c1">!=</span> <span class="pl-c1">0</span>) <span class="pl-k">else</span> <span class="pl-s">""</span> ), <span class="pl-c1">1</span>, <span class="pl-s1">dat</span>)

<span class="pl-en">print</span>(<span class="pl-s">"Res A"</span>)
<span class="pl-en">print</span>(<span class="pl-s1">resA</span>)
<span class="pl-en">print</span>(<span class="pl-s">"Res B"</span>)
<span class="pl-en">print</span>(<span class="pl-s1">resB</span>)</pre></div>

<h3 dir="auto">Output message:</h3>
<p dir="auto">I expected:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Results
Res A
['foo' 'foo' '' '']
Res B
['' '' 'foo' 'foo']"><pre class="notranslate"><code class="notranslate">Results
Res A
['foo' 'foo' '' '']
Res B
['' '' 'foo' 'foo']
</code></pre></div>
<p dir="auto">But got:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Results
Res A
['foo' 'foo' '' '']
Res B
['' '' 'f' 'f']"><pre class="notranslate"><code class="notranslate">Results
Res A
['foo' 'foo' '' '']
Res B
['' '' 'f' 'f']
</code></pre></div>

<h3 dir="auto">Numpy/Python version information:</h3>
<p dir="auto">1.18.1 3.7.6 (default, Jan  8 2020, 19:59:22)<br>
[GCC 7.3.0]</p>