[Numpy-svn] [numpy/numpy] 3205c8: BUG: copy inherited masks in MaskedArray.__array_f...

GitHub noreply at github.com
Tue Oct 21 11:24:37 EDT 2014


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: 3205c89ad3090c26fef8fd060117ee468c1b6c97
      https://github.com/numpy/numpy/commit/3205c89ad3090c26fef8fd060117ee468c1b6c97
  Author: Nathaniel J. Smith <njs at pobox.com>
  Date:   2014-10-21 (Tue, 21 Oct 2014)

  Changed paths:
    M numpy/lib/function_base.py
    M numpy/lib/tests/test_function_base.py
    M numpy/ma/core.py
    M numpy/ma/tests/test_core.py

  Log Message:
  -----------
  BUG: copy inherited masks in MaskedArray.__array_finalize__

Previously, operations which created a new masked array from an old
masked array -- e.g., np.empty_like -- would tend to result in the new
and old arrays sharing the same .mask attribute. This leads to
horrible brokenness in which writes to one array affect the other. In
particular this was responsible for part of the brokenness that
@jenshnielsen reported in gh-5184 in which np.gradient on masked
arrays would modify the original array's mask.

This fixes the worst part of the issues addressed in gh-3404, though
there's still an argument that we ought to deprecate the mask-copying
behaviour entirely so that empty_like returns an array with an empty
mask. That can wait until we find someone who cares though.

I also applied a small speedup to np.gradient (avoiding one copy);
previously this inefficiency was masking (heh) some of the problems
with masked arrays, so removing it is both an optimization and makes
it easier to test that things are working now.


  Commit: 72e9072fadc048ef9fa4f76fbf37e31058b3e24a
      https://github.com/numpy/numpy/commit/72e9072fadc048ef9fa4f76fbf37e31058b3e24a
  Author: Charles Harris <charlesr.harris at gmail.com>
  Date:   2014-10-21 (Tue, 21 Oct 2014)

  Changed paths:
    M numpy/lib/function_base.py
    M numpy/lib/tests/test_function_base.py
    M numpy/ma/core.py
    M numpy/ma/tests/test_core.py

  Log Message:
  -----------
  Merge pull request #5203 from njsmith/master

BUG: copy inherited masks in MaskedArray.__array_finalize__


Compare: https://github.com/numpy/numpy/compare/4ed4aec23912...72e9072fadc0


More information about the Numpy-svn mailing list