<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">xref: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1393203766" data-permission-text="Title is private" data-url="https://github.com/numba/numba/issues/8478" data-hovercard-type="issue" data-hovercard-url="/numba/numba/issues/8478/hovercard" href="https://github.com/numba/numba/issues/8478">numba/numba#8478</a></p>
<p dir="auto">For a long time, the <code class="notranslate">.types</code> attribute on ufuncs has contained char typecode descriptions of the implemented loops. For example:</p>
<div class="highlight highlight-text-python-console notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [1]: import numpy as np

In [2]: np.sin.types
Out[2]: 
['e-&gt;e',
 'f-&gt;f',
 'd-&gt;d',
 'f-&gt;f',
 'd-&gt;d',
 'g-&gt;g',
 'F-&gt;F',
 'D-&gt;D',
 'G-&gt;G',
 'O-&gt;O']"><pre class="notranslate">In [1]: <span class="pl-k">import</span> numpy <span class="pl-k">as</span> np

In [2]: np.sin.types
Out[2]: 
['e-&gt;e',
 'f-&gt;f',
 'd-&gt;d',
 'f-&gt;f',
 'd-&gt;d',
 'g-&gt;g',
 'F-&gt;F',
 'D-&gt;D',
 'G-&gt;G',
 'O-&gt;O']</pre></div>
<p dir="auto">Since (I think) NumPy 1.23, ISA specific dispatch loops have been added to some ufuncs, these also appear in <code class="notranslate">.types</code> as additional registrations ahead of the "original" registered loops. Example:</p>
<div class="highlight highlight-text-python-console notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [3]: np.fmax.types
Out[3]: 
['ff-&gt;f',
 'dd-&gt;d',
 'gg-&gt;g',
 '??-&gt;?',
 'bb-&gt;b',
 'BB-&gt;B',
 'hh-&gt;h',
 'HH-&gt;H',
 'ii-&gt;i',
 'II-&gt;I',
 'll-&gt;l',
 'LL-&gt;L',
 'qq-&gt;q',
 'QQ-&gt;Q',
 'ee-&gt;e',
 'ff-&gt;f',
 'dd-&gt;d',
 'gg-&gt;g',
 'FF-&gt;F',
 'DD-&gt;D',
 'GG-&gt;G',
 'mm-&gt;m',
 'MM-&gt;M',
 'OO-&gt;O']"><pre class="notranslate">In [3]: np.fmax.types
Out[3]: 
['ff-&gt;f',
 'dd-&gt;d',
 'gg-&gt;g',
 '??-&gt;?',
 'bb-&gt;b',
 'BB-&gt;B',
 'hh-&gt;h',
 'HH-&gt;H',
 'ii-&gt;i',
 'II-&gt;I',
 'll-&gt;l',
 'LL-&gt;L',
 'qq-&gt;q',
 'QQ-&gt;Q',
 'ee-&gt;e',
 'ff-&gt;f',
 'dd-&gt;d',
 'gg-&gt;g',
 'FF-&gt;F',
 'DD-&gt;D',
 'GG-&gt;G',
 'mm-&gt;m',
 'MM-&gt;M',
 'OO-&gt;O']</pre></div>
<p dir="auto">Note how the <code class="notranslate">ff-&gt;f</code>, <code class="notranslate">dd-&gt;d</code> and <code class="notranslate">gg-&gt;g</code> types occur a) first and are b) replicated later on.</p>
<p dir="auto">I'm not sure that this is actually an issue that would matter in practice except that...</p>
<ol dir="auto">
<li>In Numba, the <code class="notranslate">.types</code> is used as part of the matching logic for type specific code generation, this is now broken by the above due to the following. In NumPy 1.23 a call in Numba to <code class="notranslate">np.fmax(int64, int64)</code> resolves via <code class="notranslate">ff-&gt;f</code> as it is the first "match" (can cast to the type), whereas prior to this it would first match on <code class="notranslate">ll-&gt;l</code> (as none of the types prior to this would be a safe cast).</li>
<li>The <code class="notranslate">.types</code> description/char codes are not capturing that some of the loops registered are ISA specific, it looks like a potential mistake/bug in the output.</li>
</ol>
<p dir="auto">Essentially this ticket is to seek clarification over the intent so that I can patch Numba against it!</p>
<p dir="auto">Many thanks in advance for your help.</p>
<h3 dir="auto">Reproduce the 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
print(np.fmax.types)"><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-en">print</span>(<span class="pl-s1">np</span>.<span class="pl-s1">fmax</span>.<span class="pl-s1">types</span>)</pre></div>
<h3 dir="auto">Error message:</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="N/A"><pre class="notranslate">N/A</pre></div>
<h3 dir="auto">NumPy/Python version information:</h3>
<p dir="auto">NumPy version 1.23.1</p>
<h3 dir="auto">Context for the issue:</h3>
<p dir="auto">Impacts Numba. xref: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1393203766" data-permission-text="Title is private" data-url="https://github.com/numba/numba/issues/8478" data-hovercard-type="issue" data-hovercard-url="/numba/numba/issues/8478/hovercard" href="https://github.com/numba/numba/issues/8478">numba/numba#8478</a></p>
<p dir="auto">Apologies if this is a duplicate as it seems such an obvious bug but I could not find another issue about it. Legacy printing mode omits the plus signs for complex 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.ones(5, dtype=np.complex128)
array([1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j])
&gt;&gt;&gt; np.set_printoptions(legacy=&quot;1.13&quot;)
&gt;&gt;&gt; np.ones(5, dtype=np.complex128)
array([ 1. 0.j,  1. 0.j,  1. 0.j,  1. 0.j,  1. 0.j])"><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">ones</span>(<span class="pl-c1">5</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">complex128</span>)
<span class="pl-en">array</span>([<span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>, <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>, <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>, <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>, <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">set_printoptions</span>(<span class="pl-s1">legacy</span><span class="pl-c1">=</span><span class="pl-s">"1.13"</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">ones</span>(<span class="pl-c1">5</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">complex128</span>)
<span class="pl-en">array</span>([ <span class="pl-c1">1.</span> <span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span> <span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span> <span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span> <span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span> <span class="pl-c1">0.j</span>])</pre></div>
<p dir="auto">The output on numpy 1.13.3 is</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; np.ones(5, dtype=np.complex128)
array([ 1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j])"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">ones</span>(<span class="pl-c1">5</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">complex128</span>)
<span class="pl-en">array</span>([ <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>,  <span class="pl-c1">1.</span><span class="pl-c1">+</span><span class="pl-c1">0.j</span>])</pre></div>