title: ValueError: array is not broadcastable to correct shape - Python
body: <p>I'm receiving this error with the code below, but I didn't figure out why.</p>
  <p>I printed my objects shapes and they are the same.</p>
  <pre><code>def plot_edges_entropy(data, edges, file_path):
      plt.figure()
      
      entropy = numpy.zeros((data.rows, data.cols), float)
      print entropy.shape, edges.data.shape, data.data.shape
      entropy[edges.data == 1.0] = data.data
  
      fig = plt.imshow(entropy, extent=[0, data.cols, data.rows, 0], cmap='hot_r', vmin=0, vmax=1, interpolation='nearest')
      plt.colorbar(fig)
      plt.savefig(file_path + '.png')
      plt.close()
  
  def __init__(self, open_image=False):
      &quot;&quot;&quot;
      The Data constructor
      &quot;&quot;&quot;
      self.data = misc.imread('../TestImages/brain_noisy.jpg', flatten=True)
      self.data /= 255.0
      x, y = self.data.shape
      self.rows = x
      self.cols = y
  
      if not open_image:
          self.data = numpy.zeros((self.rows, self.cols), float)
  </code></pre>
  <p>Print statement:</p>
  <blockquote>
  <p>(211, 256) (211, 256) (211, 256)</p>
  </blockquote>
  <p>Error:</p>
  <blockquote>
  <p>entropy[edges.data == 1.0] = data.data</p>
  <p>ValueError: array is not broadcastable to correct shape</p>
  </blockquote>
  <p>If I try to assign a simple value, it works:</p>
  <pre><code> entropy[edges.data == 1.0] = 100
  </code></pre>
  <p>What's is the problem? I can assign a ndarray to another with respect to some condition?</p>
  <p>Thank you in advance.</p>