[Python-modules-commits] [python-numpy] 02/04: merge patched into master

Sandro Tosi morph at moszumanska.debian.org
Fri Jan 20 01:16:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository python-numpy.

commit d02aae6e78f9bd504db0dd9c4083d6492551a023
Merge: 3b0b172 083f1ee
Author: Sandro Tosi <morph at debian.org>
Date:   Thu Jan 19 19:32:52 2017 -0500

    merge patched into master

 debian/.git-dpm                                    |   4 +-
 ...rong-masked-median-for-some-special-cases.patch | 115 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 numpy/lib/tests/test_nanfunctions.py               |  12 +++
 numpy/ma/extras.py                                 |  19 ++--
 numpy/ma/tests/test_extras.py                      |  22 ++++
 6 files changed, 165 insertions(+), 8 deletions(-)

diff --cc debian/.git-dpm
index 23e222e,0000000..4b2efa9
mode 100644,000000..100644
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@@ -1,11 -1,0 +1,11 @@@
 +# see git-dpm(1) from git-dpm package
- 9904bd178ee091f245cf535665e5d7490c213611
- 9904bd178ee091f245cf535665e5d7490c213611
++083f1eedacba2e880991eccee3631f8f7b0deaa9
++083f1eedacba2e880991eccee3631f8f7b0deaa9
 +cdbf1e95fbf204a4ed4259bf8a210f417f2e5176
 +cdbf1e95fbf204a4ed4259bf8a210f417f2e5176
 +python-numpy_1.12.0.orig.tar.gz
 +ada03324743b6c5ad6b16e869ee08ba475d404ab
 +4331603
 +debianTag="debian/%e%v"
 +patchedTag="patched/%e%v"
 +upstreamTag="upstream/%e%u"
diff --cc debian/patches/0007-BUG-fix-wrong-masked-median-for-some-special-cases.patch
index 0000000,0000000..bc78829
new file mode 100644
--- /dev/null
+++ b/debian/patches/0007-BUG-fix-wrong-masked-median-for-some-special-cases.patch
@@@ -1,0 -1,0 +1,115 @@@
++From 083f1eedacba2e880991eccee3631f8f7b0deaa9 Mon Sep 17 00:00:00 2001
++From: Julian Taylor <jtaylor.debian at googlemail.com>
++Date: Tue, 17 Jan 2017 13:04:44 +0100
++Subject: BUG: fix wrong masked median for some special cases
++
++the masked nans which are equivalent to valid infs must be replaced
++with infs earlier otherwise the inf is lost in the masked sum of the low
++and high part.
++Closes gh-8487
++---
++ numpy/lib/tests/test_nanfunctions.py | 12 ++++++++++++
++ numpy/ma/extras.py                   | 19 +++++++++++++------
++ numpy/ma/tests/test_extras.py        | 22 ++++++++++++++++++++++
++ 3 files changed, 47 insertions(+), 6 deletions(-)
++
++diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
++index e194233..2b31045 100644
++--- a/numpy/lib/tests/test_nanfunctions.py
+++++ b/numpy/lib/tests/test_nanfunctions.py
++@@ -710,6 +710,18 @@ class TestNanFunctions_Median(TestCase):
++                 a = np.array([[inf, inf], [inf, inf]])
++                 assert_equal(np.nanmedian(a, axis=1), inf)
++ 
+++                a = np.array([[inf, 7, -inf, -9],
+++                              [-10, np.nan, np.nan, 5],
+++                              [4, np.nan, np.nan, inf]],
+++                              dtype=np.float32)
+++                if inf > 0:
+++                    assert_equal(np.nanmedian(a, axis=0), [4., 7., -inf, 5.])
+++                    assert_equal(np.nanmedian(a), 4.5)
+++                else:
+++                    assert_equal(np.nanmedian(a, axis=0), [-10., 7., -inf, -9.])
+++                    assert_equal(np.nanmedian(a), -2.5)
+++                assert_equal(np.nanmedian(a, axis=-1), [-1., -2.5, inf])
+++
++                 for i in range(0, 10):
++                     for j in range(1, 10):
++                         a = np.array([([np.nan] * i) + ([inf] * j)] * 2)
++diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
++index 1774ece..0a60ea3 100644
++--- a/numpy/ma/extras.py
+++++ b/numpy/ma/extras.py
++@@ -758,6 +758,19 @@ def _median(a, axis=None, out=None, overwrite_input=False):
++     ind[axis] = np.minimum(h, asorted.shape[axis] - 1)
++     high = asorted[tuple(ind)]
++ 
+++    def replace_masked(s):
+++        # Replace masked entries with minimum_full_value unless it all values
+++        # are masked. This is required as the sort order of values equal or
+++        # larger than the fill value is undefined and a valid value placed
+++        # elsewhere, e.g. [4, --, inf].
+++        if np.ma.is_masked(s):
+++            rep = (~np.all(asorted.mask, axis=axis)) & s.mask
+++            s.data[rep] = np.ma.minimum_fill_value(asorted)
+++            s.mask[rep] = False
+++
+++    replace_masked(low)
+++    replace_masked(high)
+++
++     # duplicate high if odd number of elements so mean does nothing
++     odd = counts % 2 == 1
++     np.copyto(low, high, where=odd)
++@@ -776,12 +789,6 @@ def _median(a, axis=None, out=None, overwrite_input=False):
++     else:
++         s = np.ma.mean([low, high], axis=0, out=out)
++ 
++-    # if result is masked either the input contained enough minimum_fill_value
++-    # so that it would be the median or all values masked
++-    if np.ma.is_masked(s):
++-        rep = (~np.all(asorted.mask, axis=axis)) & s.mask
++-        s.data[rep] = np.ma.minimum_fill_value(asorted)
++-        s.mask[rep] = False
++     return s
++ 
++ 
++diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
++index fb16d92..58ac46f 100644
++--- a/numpy/ma/tests/test_extras.py
+++++ b/numpy/ma/tests/test_extras.py
++@@ -667,6 +667,15 @@ class TestMedian(TestCase):
++         r = np.ma.median(np.ma.masked_array([[np.inf, np.inf],
++                                              [np.inf, np.inf]]), axis=None)
++         assert_equal(r, np.inf)
+++        # all masked
+++        r = np.ma.median(np.ma.masked_array([[np.inf, np.inf],
+++                                             [np.inf, np.inf]], mask=True),
+++                         axis=-1)
+++        assert_equal(r.mask, True)
+++        r = np.ma.median(np.ma.masked_array([[np.inf, np.inf],
+++                                             [np.inf, np.inf]], mask=True),
+++                         axis=None)
+++        assert_equal(r.mask, True)
++ 
++     def test_non_masked(self):
++         x = np.arange(9)
++@@ -992,6 +1001,19 @@ class TestMedian(TestCase):
++             assert_equal(np.ma.median(a, axis=0), inf)
++             assert_equal(np.ma.median(a, axis=1), inf)
++ 
+++            a = np.array([[inf, 7, -inf, -9],
+++                          [-10, np.nan, np.nan, 5],
+++                          [4, np.nan, np.nan, inf]],
+++                          dtype=np.float32)
+++            a = np.ma.masked_array(a, mask=np.isnan(a))
+++            if inf > 0:
+++                assert_equal(np.ma.median(a, axis=0), [4., 7., -inf, 5.])
+++                assert_equal(np.ma.median(a), 4.5)
+++            else:
+++                assert_equal(np.ma.median(a, axis=0), [-10., 7., -inf, -9.])
+++                assert_equal(np.ma.median(a), -2.5)
+++            assert_equal(np.ma.median(a, axis=1), [-1., -2.5, inf])
+++
++             for i in range(0, 10):
++                 for j in range(1, 10):
++                     a = np.array([([np.nan] * i) + ([inf] * j)] * 2)
diff --cc debian/patches/series
index 3e2b507,0000000..1d97c2e
mode 100644,000000..100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@@ -1,6 -1,0 +1,7 @@@
 +03_force_f2py_version.patch
 +10_use_local_python.org_object.inv_sphinx.diff
 +python3-soabi.patch
 +adapt_swig_docs_to_debian.patch
 +0005-Dont-fail-if-we-cant-import-mingw32.patch
 +0006-disable-asserts-on-ppc-with-broken-malloc-only-longd.patch
++0007-BUG-fix-wrong-masked-median-for-some-special-cases.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-numpy.git



More information about the Python-modules-commits mailing list