title: Numpy: Array of class instances
body: <p>This might be a dumb question, but say i want to build a program from bottom-up like so:</p>
  
  <pre><code>class Atom(object):
      def __init__(self):
          '''
          Constructor
          '''
      def atom(self, foo, bar):
          #...with foo and bar being arrays of atom Params of lengths m &amp; n
          "Do what atoms do"
          return atom_out
  </code></pre>
  
  <p>...i can put my instances in a dictionary:</p>
  
  <pre><code>class Molecule(Atom):
      def __init__(self):
  
  
      def structure(self, a, b):
          #a = 2D array of size (num_of_atoms, m); 'foo' Params for each atom
          #b = 2D array of size (num_of_atoms, n); 'bar' Params for each atom
  
          unit = self.atom()
          fake_array = {"atom1": unit(a[0], b[0]),
                        "atom2": unit(a[1], b[1]),
                         :                      :                    :
                         :                      :                    :}
  
      def chemicalBonds(self, this, that, theother):
          :                         :                      :
          :                         :                      :
  </code></pre>
  
  <p>My question is, is there a way to do this with numpy arrays so that each element in "<code>real_array</code>" would be an instance of <code>atom</code>--i.e., the output of the individual computations of <code>atom</code> function? I can extend this to <code>class Water(molecule):</code> which would perform fast numpy operations on the large <code>structure</code> and <code>chemicalBonds</code> outputs, hence the need for arrays...Or is it the case that i'm going about this the wrong way?</p>
  
  <p>Also if i am on the right track, i'd appreciate if you wanted to throw in any tips on how to structure a "hierarchical program" like this, as i'm not sure i'm doing the above correctly and recently discovered that i don't know what i'm doing.</p>
  
  <p>Thanks in advance.</p>