title: Array of a subclass of numpy
body: <p>I have a problem.  Problem is: I want to create a subclass of numpy array, and then make an array of objects of that type.  When I reference an item in that array, I want it still to be an instance of that subclass.  Instead, it is an instance of numpy array.</p>
  
  <p>Here is a test that fails:</p>
  
  <pre><code>import numpy as np
  
  
  class ImageWrapper(np.ndarray):
  
      def __new__(cls, image_data):
          assert image_data.ndim in (2, 3)
          return image_data.view(cls)
  
      @property
      def n_colours(self): 
          return 1 if self.ndim==2 else self.shape[2]
  
  
  n_frames = 10
  frames = [ImageWrapper(np.random.randint(255, size = (20, 15, 3)).astype('uint8')) for _ in xrange(n_frames)]
  video = np.array(frames)
  assert video[0].n_colours == 3
  </code></pre>
  
  <p>Gives me: AttributeError: 'numpy.ndarray' object has no attribute 'n_colours'</p>
  
  <p>How can I make this work?</p>
  
  <p>Things tried already:</p>
  
  <ul>
  <li>Setting subok=True when constructing the video - this only works when constructing an array from a single instance of the subclass object, not a list.</li>
  <li>Setting dtype=object or dtype=ImageWrapper doesn't work</li>
  </ul>
  
  <p>I recognize that I could just make video a list, but it would be preferable to keep it as a numpy array for other reasons.</p>