[Numpy-svn] [numpy/numpy] 2f1e27: BUG: fix nanmedian on arrays containing inf

GitHub noreply at github.com
Thu Oct 16 13:29:08 EDT 2014


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: 2f1e27610453f901e81cd892b2aa3b3a2ac30819
      https://github.com/numpy/numpy/commit/2f1e27610453f901e81cd892b2aa3b3a2ac30819
  Author: Julian Taylor <jtaylor.debian at googlemail.com>
  Date:   2014-10-14 (Tue, 14 Oct 2014)

  Changed paths:
    M numpy/lib/tests/test_nanfunctions.py
    M numpy/ma/core.py
    M numpy/ma/extras.py
    M numpy/ma/tests/test_extras.py

  Log Message:
  -----------
  BUG: fix nanmedian on arrays containing inf

There are two issues:
A masked divide of an infinite value is a masked value which means one
can't use np.ma.mean to compute the median as infinity division is well
defined.
This behaviour seems wrong to me but it also looks intentional so
changing it is not appropriate for a bugfix release.

The second issue is that the ordering of the sorted masked array is
undefined for equal values, the sorting considers infinity the largest
floating point value which is not correct in respect to sorting where
nan is considered larger. This is fixed by changing the
minimum_fill_value to nan for float data in the masked sorts.

Closes gh-5138


  Commit: 443a49a271e6d7c4c1dda72fe721eaed318ff764
      https://github.com/numpy/numpy/commit/443a49a271e6d7c4c1dda72fe721eaed318ff764
  Author: Charles Harris <charlesr.harris at gmail.com>
  Date:   2014-10-16 (Thu, 16 Oct 2014)

  Changed paths:
    M numpy/lib/tests/test_nanfunctions.py
    M numpy/ma/core.py
    M numpy/ma/extras.py
    M numpy/ma/tests/test_extras.py

  Log Message:
  -----------
  Merge pull request #5182 from juliantaylor/nanmedian-inf

BUG: fix nanmedian on arrays containing inf


Compare: https://github.com/numpy/numpy/compare/4c0747d5c2cb...443a49a271e6


More information about the Numpy-svn mailing list