numpy/numpy — pull request #2703 by astrofrog (2012-10-31 19:00:21+00:00)
Title: Don't reset the fill_value of a MaskedArray when calling view() with no dtype

This is a follow-up to:

http://mail.scipy.org/pipermail/numpy-discussion/2012-October/064291.html

Before this PR, the behavior of `MaskedArray.view()`` was:

>>> from numpy import ma
>>> x = ma.array([1,2,3])
>>> x.fill_value = 1
>>> x.view(ma.MaskedArray)
masked_array(data = [1 2 3],
mask = False,
fill_value = 999999)

And with this PR, it should be

>>> from numpy import ma
>>> x = ma.array([1,2,3])
>>> x.fill_value = 1
>>> x.view(ma.MaskedArray)
masked_array(data = [1 2 3],
mask = False,
fill_value = 1)

Is there a reason for the original behavior? My guess is that if ``dtype`` changes, then it makes sense to reset the ``fill_value`` since ``fill_value`` is type-dependent, but if the ``dtype`` stays the same, why reset the ``fill_value``? Does the proposed behavior not make more sense?