title: Numba try: if array.shape[1] - error: tuple index out of range. works without numba, doesn't work with @njit(fastmath=True, nogil=True, cache=True)
body: <p>Numba 0.53.1, Python 3.7.9, Windows 10 64bit</p>
  <p>This doctest works fine:</p>
  <pre><code>import numpy as np
  
  def example_numba_tri(yp):
      &quot;&quot;&quot;
      &gt;&gt;&gt; example_numba_tri(np.array([0.1, 0.5, 0.2, 0.3, 0.1, 0.7, 0.6, 0.4, 0.1]))
      array([[0.1, 0.3, 0.6],
             [0.5, 0.1, 0.4],
             [0.2, 0.7, 0.1]])
      &quot;&quot;&quot;
      try:
          if yp.shape[1] == 3:
              pass
      except:
          yp = yp.reshape(int(len(yp) / 3), -1, order='F')
  
      return yp
  </code></pre>
  <p>Just add <code>@njit(fastmath=True, nogil=True, cache=True)</code>:</p>
  <pre><code>from numba import njit
  import numpy as np
  
  @njit(fastmath=True, nogil=True, cache=True)
  def example_numba_tri(yp):
      &quot;&quot;&quot;
      &gt;&gt;&gt; example_numba_tri(np.array([0.1, 0.5, 0.2, 0.3, 0.1, 0.7, 0.6, 0.4, 0.1]))
      array([[0.1, 0.3, 0.6],
             [0.5, 0.1, 0.4],
             [0.2, 0.7, 0.1]])
      &quot;&quot;&quot;
      try:
          if yp.shape[1] == 3:
              pass
      except:
          yp = yp.reshape(int(len(yp) / 3), -1, order='F')
  
      return yp
  </code></pre>
  <p>and get an error:</p>
  <pre><code>    numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
      Internal error at &lt;numba.core.typeinfer.StaticGetItemConstraint object at 0x0000020CB55A7608&gt;.
      tuple index out of range
      During: typing of static-get-item at C:/U1/main.py (1675)
      Enable logging at debug level for details.
      
      File &quot;main.py&quot;, line 1675:
      def example_numba_tri(yp):
          &lt;source elided&gt;
          try:
              if yp.shape[1] == 3:
              ^
  </code></pre>
  <p>How to fix it and why this happen? Or this is a bug?
  I read <a href="https://numba.pydata.org/numba-doc/dev/reference/pysupported.html#pysupported-exception-handling" rel="nofollow noreferrer">https://numba.pydata.org/numba-doc/dev/reference/pysupported.html#pysupported-exception-handling</a> , but seems I did everything as it written there.</p>
  <p>Updates:</p>
  <ol>
  <li><a href="https://github.com/numba/numba/issues/6872" rel="nofollow noreferrer">https://github.com/numba/numba/issues/6872</a></li>
  <li>Also this was useful for me <a href="https://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile" rel="nofollow noreferrer">https://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile</a></li>
  <li>profiling and restructing helped me convert to numba only most cpu-intensive parts</li>
  <li>numba.pydata.org/numba-doc/dev/reference/numpysupported.html seems
  no support for <code>order</code> (<code>order='F'</code>)</li>
  </ol>