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

GitHub noreply at github.com
Sun Oct 26 10:17:59 EDT 2014


  Branch: refs/heads/maintenance/1.9.x
  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: 69707322db207b503fb6be8227071b2231cc7a25
      https://github.com/numpy/numpy/commit/69707322db207b503fb6be8227071b2231cc7a25
  Author: Julian Taylor <jtaylor.debian at googlemail.com>
  Date:   2014-10-26 (Sun, 26 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/c6900b2a0dec...69707322db20


More information about the Numpy-svn mailing list