title: Determining input argument type for jitclass method
body: <p>I'm working on a jitclass in which one of the methods can accept an input argument of <code>int</code>, <code>float</code>, or <code>numpy.ndarray</code>. I need to be able to determine if the argument is and array or any of the other two types. I've tried using <code>isinstance</code> as shown in the <code>interp</code> method below:</p>
  <pre><code>spec = [('x', float64[:]),
          ('y', float64[:])]
  
  
  @jitclass(spec)
  class Lookup:
      def __init__(self, x, y):
          self.x = x
          self.y = y
  
      def interp(self, x0):
          if isinstance(x0, (float, int)):
              result = self._interpolate(x0)
          elif isinstance(x0, np.ndarray):
              result = np.zeros(x0.size)
              for i in range(x0.size):
                  result[i] = self._interpolate(x0[i])
          else:
              raise TypeError(&quot;`interp` method can only accept types of float, int, or ndarray.&quot;)
          return result
  
      def _interpolate(self, x0):
          x = self.x
          y = self.y
          if x0 &lt; x[0]:
              return y[0]
          elif x0 &gt; x[-1]:
              return y[-1]
          else:
              for i in range(len(x) - 1):
                  if x[i] &lt;= x0 &lt;= x[i + 1]:
                      x1, x2 = x[i], x[i + 1]
                      y1, y2 = y[i], y[i + 1]
  
                      return y1 + (y2 - y1) / (x2 - x1) * (x0 - x1)
  </code></pre>
  <p>But I get the following error:</p>
  <pre><code>numba.errors.TypingError: Failed at nopython (nopython frontend)
  Failed at nopython (nopython frontend)
  Untyped global name 'isinstance': cannot determine Numba type of &lt;class 'builtin_function_or_method'&gt;
  File &quot;Lookups.py&quot;, line 17
  [1] During: resolving callee type: BoundFunction((&lt;class 'numba.types.misc.ClassInstanceType'&gt;, 'interp') for instance.jitclass.Lookup#2167664ca28&lt;x:array(float64, 1d, A),y:array(float64, 1d, A)&gt;)
  [2] During: typing of call at &lt;string&gt; (3)
  </code></pre>
  <p>Is there a way to determine whether an input argument is of a certain type when using jitclasses or in nopython mode?</p>
  <h1>Edit</h1>
  <p>I should have mentioned this before but using the <code>type</code> built-in also does not seem to work. For example if I replace the <code>interp</code> method with:</p>
  <pre><code>def interp(self, x0):
          if type(x0) == float or type(x0) == int:
              result = self._interpolate(x0)
          elif type(x0) == np.ndarray:
              result = np.zeros(x0.size)
              for i in range(x0.size):
                  result[i] = self._interpolate(x0[i])
          else:
              raise TypeError(&quot;`interp` method can only accept types of float, int, or ndarray.&quot;)
          return result
  </code></pre>
  <p>I get the following error:</p>
  <pre><code>numba.errors.TypingError: Failed at nopython (nopython frontend)
  Failed at nopython (nopython frontend)
  Invalid usage of == with parameters (class(int64), Function(&lt;class 'float'&gt;))
  </code></pre>
  <p>Which I think is referring to the comparison of python <code>float</code> and numba's <code>int64</code> when I do something like <code>lookup_object.interp(370)</code> for example.</p>