[Numpy-tickets] [NumPy] #979: broken arithmetic with masked arrays
NumPy
numpy-tickets@scipy....
Tue Jan 6 18:52:36 CST 2009
#979: broken arithmetic with masked arrays
----------------------+-----------------------------------------------------
Reporter: jguyer | Owner: pierregm
Type: defect | Status: new
Priority: normal | Milestone: 1.3.0
Component: numpy.ma | Version: none
Severity: normal | Keywords:
----------------------+-----------------------------------------------------
I'm getting unexpected broadcasting and raveling of masked values in basic
arithmetic. I don't know if this is related to #826
{{{
#!python
>>> import numpy
>>> numpy.__version__
'1.3.0.dev6298'
>>> A = numpy.ma.array([[1.],
... [2.],
... [3.]], mask=[[False],
... [True],
... [True]])
>>> B = numpy.array([[2., 3.],
... [4., 5.],
... [6., 7.]])
>>> A * B
masked_array(data =
[[2.0 --]
[-- 2.0]
[-- --]],
mask =
[[False True]
[ True False]
[ True True]],
fill_value = 1e+20)
>>> A.data * B
array([[ 2., 3.],
[ 8., 10.],
[ 18., 21.]])
>>> (A * B).data
array([[ 2., 3.],
[ 2., 2.],
[ 3., 3.]])
}}}
With NumPy 1.2, the mask is still broken, but the value is correct
{{{
#!python
>>> import numpy
>>> numpy.__version__
'1.2.0'
>>> A = numpy.ma.array([[1.],
... [2.],
... [3.]], mask=[[False],
... [True],
... [True]])
>>> B = numpy.array([[2., 3.],
... [4., 5.],
... [6., 7.]])
>>> A * B
masked_array(data =
[[2.0 --]
[-- 10.0]
[-- --]],
mask =
[[False True]
[ True False]
[ True True]],
fill_value=1e+20)
>>> A.data * B
array([[ 2., 3.],
[ 8., 10.],
[ 18., 21.]])
>>> (A * B).data
array([[ 2., 3.],
[ 8., 10.],
[ 18., 21.]])
}}}
I thought I'd seen cases where NumPy 1.1 returned both the correct value
and mask, but I'm not able to reproduce now. NumPy 1.1 and 1.2 behave the
same.
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/979>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list