title: Numpy broadcasting rules when using masked_where (or do they not apply?)
body: <p>I would like to use broadcasting to use values from one array (lower dimension) to mask another array (higher dimension).</p>
  
  <p>An example would be</p>
  
  <pre><code>a= np.arange(9).reshape(3,3)
  b= np.arange(3)
  </code></pre>
  
  <p>what I tried is</p>
  
  <pre><code>c=np.ma.masked_where(b[:,np.newaxis]&gt;1, a)
  </code></pre>
  
  <p>but it fails with "<code>IndexError: Inconsistant[sic] shape between the condition and the input (got(3,1) and (3,3))</code>"</p>
  
  <p>which is perplexing since broadcasting should apply here and <code>b</code> should broadcast onto <code>a</code>.
  A work around is to build a temporary <code>d</code> array of the right size</p>
  
  <pre><code>d=np.broadcast_arrays(b[:,np.newaxis],a)[0]
  </code></pre>
  
  <p>and use it in the <code>masked_where</code> statement</p>
  
  <pre><code>c=np.ma.masked_where(d&gt;1,a)
  </code></pre>
  
  <p>but this is goes against the paradigm of avoiding temp arrays by using <code>np.newaxis</code>.</p>
  
  <p>OBTW, using the where command does allow broadcasting in this manner</p>
  
  <pre><code>c=np.where(b[:,np.newaxis]&gt;1, 0.0, a)
  </code></pre>
  
  <p>works as expected.</p>
  
  <p>Additionally,if the condition in the <code>masked_where</code> is always false, the command will execute without error...</p>
  
  <pre><code>c=np.ma.masked_where(b[:,np.newaxis]&gt;5, 0.0, a)
  </code></pre>
  
  <p>will yield <code>a</code>.</p>
  
  <p>FWIW, I'm using numpy 1.6.1.</p>