[pyresample] 01/02: Fix comaptibility with numpy 1.13

Antonio Valentino a_valentino-guest at moszumanska.debian.org
Sat Sep 9 10:49:39 UTC 2017


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

a_valentino-guest pushed a commit to branch master
in repository pyresample.

commit db640861a89881badf866c09a80b6e7d9e8ace6c
Author: Antonio Valentino <antonio.valentino at tiscali.it>
Date:   Sat Sep 9 09:35:40 2017 +0000

    Fix comaptibility with numpy 1.13
---
 debian/changelog                                   |  8 +++
 ...n-mask-array-usage-in-gaussian-resampling.patch | 71 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 80 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 28ad123..55be419 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+pyresample (1.5.0-4) UNRELEASED; urgency=medium
+
+  * debian/patches
+    - new 0003-Fix-boolean-mask-array-usage-in-gaussian-resampling.patch
+      (backported form upstream) fix compatibility with numpy 1.13
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Sat, 09 Sep 2017 09:33:44 +0000
+
 pyresample (1.5.0-3) unstable; urgency=medium
 
   * Team upload.
diff --git a/debian/patches/0003-Fix-boolean-mask-array-usage-in-gaussian-resampling.patch b/debian/patches/0003-Fix-boolean-mask-array-usage-in-gaussian-resampling.patch
new file mode 100644
index 0000000..334f6ce
--- /dev/null
+++ b/debian/patches/0003-Fix-boolean-mask-array-usage-in-gaussian-resampling.patch
@@ -0,0 +1,71 @@
+From: Antonio Valentino <antonio.valentino at tiscali.it>
+Date: Sat, 9 Sep 2017 09:31:36 +0000
+Subject: Fix boolean mask array usage in gaussian resampling
+
+In numpy 1.13 it is illegal to index an array with a boolean
+array of a different size.
+---
+ pyresample/kd_tree.py           | 21 ++++++++++++++++-----
+ pyresample/test/test_kd_tree.py | 10 ++++++----
+ 2 files changed, 22 insertions(+), 9 deletions(-)
+
+diff --git a/pyresample/kd_tree.py b/pyresample/kd_tree.py
+index e08ca84..2f76b7b 100644
+--- a/pyresample/kd_tree.py
++++ b/pyresample/kd_tree.py
+@@ -807,11 +807,22 @@ def get_sample_from_neighbour_info(resample_type, output_shape, data,
+ 
+             # Calculate final stddev
+             new_valid_index = (count > 1)
+-            v1 = norm[new_valid_index]
+-            v2 = norm_sqr[new_valid_index]
+-            stddev[new_valid_index] = np.sqrt(
+-                (v1 / (v1 ** 2 - v2)) * stddev[new_valid_index])
+-            stddev[~new_valid_index] = np.NaN
++            if stddev.ndim >= 2:
++                # If given more than 1 input data array
++                new_valid_index = new_valid_index[:, 0]
++                for i in range(stddev.shape[-1]):
++                    v1 = norm[new_valid_index, i]
++                    v2 = norm_sqr[new_valid_index, i]
++                    stddev[new_valid_index, i] = np.sqrt(
++                        (v1 / (v1 ** 2 - v2)) * stddev[new_valid_index, i])
++                    stddev[~new_valid_index, i] = np.NaN
++            else:
++                # If given single input data array
++                v1 = norm[new_valid_index]
++                v2 = norm_sqr[new_valid_index]
++                stddev[new_valid_index] = np.sqrt(
++                    (v1 / (v1 ** 2 - v2)) * stddev[new_valid_index])
++                stddev[~new_valid_index] = np.NaN
+ 
+         # Add fill values
+         result[np.invert(result_valid_index)] = fill_value
+diff --git a/pyresample/test/test_kd_tree.py b/pyresample/test/test_kd_tree.py
+index 80dbec0..eafc689 100644
+--- a/pyresample/test/test_kd_tree.py
++++ b/pyresample/test/test_kd_tree.py
+@@ -345,17 +345,19 @@ class Test(unittest.TestCase):
+             self.assertTrue(any(['Possible more' in str(
+                 x.message) for x in w]), 'Failed to create correct neighbour radius warning')
+         cross_sum = res.sum()
+-        cross_sum_stddev = stddev.sum()
+         cross_sum_counts = counts.sum()
+         expected = 1461.84313918
+-        expected_stddev = 0.446204424799
++        expected_stddev = [0.446193170875, 0.443606880035, 0.438586349519]
+         expected_counts = 4934802.0
+         self.assertTrue(res.shape == stddev.shape and stddev.shape ==
+                         counts.shape and counts.shape == (800, 800, 3))
+         self.assertAlmostEqual(cross_sum, expected,
+                                msg='Swath multi channel resampling gauss failed on data')
+-        self.assertAlmostEqual(cross_sum_stddev, expected_stddev,
+-                               msg='Swath multi channel resampling gauss failed on stddev')
++        for i, e_stddev in enumerate(expected_stddev):
++            cross_sum_stddev = stddev[:, :, i].sum()
++            print(cross_sum_stddev, e_stddev)
++            self.assertAlmostEqual(cross_sum_stddev, e_stddev,
++                                   msg='Swath multi channel resampling gauss failed on stddev (channel {})'.format(i))
+         self.assertAlmostEqual(cross_sum_counts, expected_counts,
+                                msg='Swath multi channel resampling gauss failed on counts')
+ 
diff --git a/debian/patches/series b/debian/patches/series
index b939e25..ebad94b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 0001-fix-doc-build.patch
 0002-fix-proj4-initialization.patch
+0003-Fix-boolean-mask-array-usage-in-gaussian-resampling.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pyresample.git



More information about the Pkg-grass-devel mailing list