NumPy Trac numpy-tickets@scipy....
Tue Sep 7 16:39:26 CDT 2010

```#1606: broadcasting masked arrays in exponents
------------------------+---------------------------------------------------
Reporter:  weathergod  |       Owner:  pierregm
Type:  defect      |      Status:  new
Priority:  normal      |   Milestone:  2.0.0
Component:  numpy.ma    |     Version:  1.5.0
Keywords:              |
------------------------+---------------------------------------------------

Comment(by weathergod):

I should have used the Preview button... corrected version below.

{{{
import numpy as np

a_2d = np.random.random((3, 5))
b_1d = np.random.random(5)
b_2d = np.vstack((b_1d, b_1d, b_1d))

0.25))
0.25))

print a_2d**b_2d

print a_2d**b_1d

print a_ma_2d**b_ma_2d

print a_ma_2d**b_ma_1d

print a_2d**b_ma_2d

print a_2d**b_ma_1d
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bvr/Programs/numpy/numpy/ma/core.py", line 3697, in __rpow__
return power(other, self)
File "/home/bvr/Programs/numpy/numpy/ma/core.py", line 6043, in power
m |= invalid
ValueError: invalid return array shape

# Now, test broadcasting of the other side of the operator
c = np.random.random(5)

print c**b_ma_2d

print c_ma**b_2d
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bvr/Programs/numpy/numpy/ma/core.py", line 3693, in __pow__
return power(self, other)
File "/home/bvr/Programs/numpy/numpy/ma/core.py", line 6043, in power
m |= invalid
ValueError: invalid return array shape
}}}

So, this fails if we broadcast the masked array portion of a power
expression and the other value is a ndarray.
Note, the same also occurs if we broadcast a masked array in order to
raise it to powers indicated by an ndarray.

--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1606#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project
```