summaryrefslogtreecommitdiff
path: root/numpy/ma/tests/test_extras.py
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-10-13 22:45:03 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-10-14 23:19:06 +0200
commit2f1e27610453f901e81cd892b2aa3b3a2ac30819 (patch)
treef0dfd1a5db083df2bb47070e910a3feed9cc3f65 /numpy/ma/tests/test_extras.py
parent8b1f90a227b5fcf2a481c973e522693758c9f20f (diff)
downloadpython-numpy-2f1e27610453f901e81cd892b2aa3b3a2ac30819.tar.gz
python-numpy-2f1e27610453f901e81cd892b2aa3b3a2ac30819.tar.bz2
python-numpy-2f1e27610453f901e81cd892b2aa3b3a2ac30819.zip
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
Diffstat (limited to 'numpy/ma/tests/test_extras.py')
-rw-r--r--numpy/ma/tests/test_extras.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
index 6ce1dc346..d7bc765a9 100644
--- a/numpy/ma/tests/test_extras.py
+++ b/numpy/ma/tests/test_extras.py
@@ -504,6 +504,9 @@ class TestApplyOverAxes(TestCase):
class TestMedian(TestCase):
+ def test_pytype(self):
+ r = np.ma.median([[np.inf, np.inf], [np.inf, np.inf]], axis=-1)
+ assert_equal(r, np.inf)
def test_2d(self):
# Tests median w/ 2D