title: How to make numba(nopython=true) work with 1D numpy.ndarray input with unknown number of elements
body: <p>I'm porting a (mathematically complicated/involved but few operations) homebrew empirical distribution class from C++/MATLAB (I have both) to Python.</p>
  
  <p>The file has some 1100 lines of code including comments and test data including a</p>
  
  <pre><code>if __name__ == "__main__": 
  </code></pre>
  
  <p>at the bottom of the file.</p>
  
  <p>line 83 has the function declaration: <code>def cdf(self, x):</code></p>
  
  <p>Which compiled and ran fine it's just very slow so I want to compile with <code>@numba.jit(nopython=True)</code> to make it run faster.</p>
  
  <p>However, the compilation died on one of the earliest lines of the function (only comments in front of it) line 85 of the file <code>npts=len(x)</code>.</p>
  
  <p>The message ends with :</p>
  
  <pre class="lang-py prettyprint-override"><code>[1] During: typing of argument at
  C:\Users\kdalbey\Canopy\scripts\empDist.py (85)
  --%&lt;-----------------------------------------------------------------
  
  File "Canopy\scripts\empDist.py", line 85
  
  This error may have been caused by the following argument(s):
  - argument 0: cannot determine Numba type of &lt;class '__main__.empDist'&gt;
  </code></pre>
  
  <p>Now I really did a  <code>import numpy as np</code> at the top of the file but for clarity of this message below I've tried to replace <code>np</code> with <code>numpy</code>. But I might have missed a few.</p>
  
  <p>If I use <code>npts=x.size</code>, I get the same error message.</p>
  
  <p>So I try to type <code>x</code> as:</p>
  
  <pre><code>@numba.jit(nopython=True)
  def cdf(self, x: numpy.ndarray(dtype=numpy.float64)):
  </code></pre>
  
  <p>And I get following error</p>
  
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  C:\Users\kdalbey\Canopy\scripts\empDist.py in &lt;module&gt;()
       15 np.set_printoptions(precision=16)
       16 
  ---&gt; 17 class empDist:
       18     def __init__(self, xdata):
       19         npts=len(xdata)
  C:\Users\kdalbey\Canopy\scripts\empDist.py in empDist()
       81 
       82     @numba.jit(nopython=True)
  ---&gt; 83     def cdf(self, x: np.ndarray(dtype=np.float64)):
       84         # compute the value of cdf at vector of points x
       85         npts = x.size
  TypeError: Required argument 'shape' (pos 1) not found
  </code></pre>
  
  <p>But I don't know how many elements the <code>1D numpy.ndarray</code> has in advance (it's arbitrary)</p>
  
  <p>I guessed that I might be able to do a</p>
  
  <pre><code>@numba.jit(nopython=True)
  def cdf(self, x: numpy.ndarray(shape=(), dtype=numpy.float64)):
  </code></pre>
  
  <p>and it gets past that error only to go back to the</p>
  
  <pre><code>[1] During: typing of argument at
  C:\Users\kdalbey\Canopy\scripts\empDist.py (85)
  --%&lt;-----------------------------------------------------------------
  File "Canopy\scripts\empDist.py", line 85
  This error may have been caused by the following argument(s):
  - argument 0: cannot determine Numba type of &lt;class '__main__.empDist'&gt;
  </code></pre>
  
  <p>And it's the same error if I do either a <code>npts=int(x.size)</code> or <code>npts=numpy.int32(x.size)</code> so I'm figuring the problem is with <code>x</code>.</p>