title: Numba: UntypedAttributeError in class method
body: <p>I have the following class and method that should convolve an array with a kernel.</p>
  
  <pre><code>import numpy as np
  from numpy.fft import fft2 as FFT, ifft2 as IFFT
  from PIL import Image
  from tqdm import trange, tqdm
  from numba import jit
  
  from time import sleep
  
  import _kernel
  
  class convolve(object):
      """ contains methods to convolve two images """
      def __init__(self, image_array, kernel):
          self.array = image_array
          self.kernel = kernel
  
          self.__rangeX_ = self.array.shape[0]
          self.__rangeY_ = self.array.shape[1]
  
          self.__rangeKX_ = self.kernel.shape[0]
          self.__rangeKY_ = self.kernel.shape[1]
  
          if (self.__rangeKX_ &gt;= self.__rangeX_ or \
              self.__rangeKY_ &gt;= self.__rangeY_):
              raise ValueError('Must submit suitable sizes for convolution.')
  
      @jit(nopython=True)
      def spaceConv(self):
          """ normal convolution, O(N^2*n^2). This is usually too slow """
  
          # pad array for convolution
          offsetX = self.__rangeKX_ // 2
          offsetY = self.__rangeKY_ // 2
  
          self.array = np.pad(self.array,               \
              [(offsetY, offsetY), (offsetX, offsetX)], \
                 mode='constant', constant_values=0)
  
          # this is the O(N^2) part of this algorithm
          for i in xrange(self.__rangeX_ - 2*offsetX):
              for j in xrange(self.__rangeY_ - 2*offsetY):
                  # Now O(n^2) portion
                  total = 0.0
                  for k in xrange(2*offsetX+1):
                      for t in xrange(2*offsetY+1):
                          total += self.kernel[k][t] * self.array[i+k][j+t]
                  self.array[i+offsetX][j+offsetY] = total
  
          return self.array
  </code></pre>
  
  <p>As an additional note (in case anyone asks), _kernel just generates specific kernels one may want to convolve the image with (e.g. Gaussian, Moffat, etc.), so it has nothing to do with this class.</p>
  
  <p>When I call the above class on an image and kernel, I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "fftconv.py", line 147, in &lt;module&gt;
      plt.imshow(conv.spaceConv(), interpolation='none', cmap='gray')
    File "/root/anaconda2/lib/python2.7/site-packages/numba/dispatcher.py", line 304, in _compile_for_args
      raise e
  numba.errors.UntypedAttributeError: Caused By:
  Traceback (most recent call last):
    File "/root/anaconda2/lib/python2.7/site-packages/numba/compiler.py", line 249, in run
      stage()
    File "/root/anaconda2/lib/python2.7/site-packages/numba/compiler.py", line 465, in stage_nopython_frontend
      self.locals)
    File "/root/anaconda2/lib/python2.7/site-packages/numba/compiler.py", line 789, in type_inference_stage
      infer.propagate()
    File "/root/anaconda2/lib/python2.7/site-packages/numba/typeinfer.py", line 717, in propagate
      raise errors[0]
  UntypedAttributeError: Unknown attribute "rangeKX" of type pyobject
  File "fftconv.py", line 45
  [1] During: typing of get attribute at fftconv.py (45)
  
  Failed at nopython (nopython frontend)
  Unknown attribute "rangeKX" of type pyobject
  File "fftconv.py", line 45
  [1] During: typing of get attribute at fftconv.py (45)
  
  This error may have been caused by the following argument(s):
  - argument 0: cannot determine Numba type of value &lt;__main__.convolve object at 0xaff5628c&gt;
  </code></pre>
  
  <p>Usually I'm pretty good at tracing through Python errors to the cause, but because I'm not familiar with the inner-works of Numba, I'm not sure why it doesn't know what type <code>offsetX</code> is. Any suggestions?</p>