title: Error: Setting an array element with a sequence. Python / Numpy
body: <p>I'm receiving this error when trying to assign an array to another array specific position.
  I was doing this before creating simple lists and doing such assignment. But Numpy is faster than simple lists and I was trying to use it now.</p>
  
  <p>The problem is cause I have a 2D array that stores some data and, in my code, I have, e.g., to calculate the gradient for each position value, so I create another 2D array where each position stores the gradient for its value.</p>
  
  <pre><code>import numpy as np
  
  cols = 2
  rows = 3
  
  # This works
  matrix_a = []
  
  for i in range(rows):
      matrix_a.append([0.0] * cols)
  
  print matrix_a    
  matrix_a[0][0] = np.matrix([[0], [0]])    
  print matrix_a
  
  # This doesn't work
  matrix_b = np.zeros((rows, cols)) 
  print matrix_b   
  
  matrix_b[0, 0] = np.matrix([[0], [0]])
  </code></pre>
  
  <p>What happens is 'cause I have a class defining a <strong>np.zeros((rows, cols))</strong> object, that stores information about some data, simplifying, e.g., images data. </p>
  
  <pre><code>class Data2D(object):
      def __init__(self, rows=200, cols=300):
          self.cols = cols
          self.rows = rows
          # The 2D data structure
          self.data = np.zeros((rows, cols))
  </code></pre>
  
  <p>In a specific method, I have to calculate the gradient for this data, which is a 2 x 2 matrix (cause of this I would like to use <strong>ndarray</strong>, and not a simple <strong>array</strong>), and, to do this, I create another instance of this object to store this new data, in which each point (pixel) should store its gradient. I was using simple lists, which works, but I though I could gain some performance with numpy.</p>
  
  <p>There is a way to work around this? Or a better way to do such thing?
  I know that I can define the array type to <strong>object</strong>, but I don't know if I lose performance doing such thing.</p>
  
  <p>Thank you.</p>