Commit 7f2a618e authored by Andreas Tille's avatar Andreas Tille
Browse files

Backport Python 3.7 test fix from upstream to fix Python index test with empty comparison

parent fea72686
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
simpleitk (1.0.1-3) UNRELEASED; urgency=medium

  [ Dylan Aïssi ]
  * Team upload.
  * Add references to registries.

 -- Dylan Aïssi <bob.dybian@gmail.com>  Wed, 25 Apr 2018 23:04:26 +0200
  [ Matthias Klose ]
  * Backport Python 3.7 test fix from upstream to fix Python index test
    with empty comparison
    Closes: #912583

 -- Andreas Tille <tille@debian.org>  Sun, 02 Dec 2018 22:34:26 +0100

simpleitk (1.0.1-2) unstable; urgency=medium

+47 −0
Original line number Diff line number Diff line
From: Bradley Lowekamp <blowekamp@mail.nih.gov>
Date: Thu, 16 Aug 2018 09:50:39 -0400
Bug-Debian: https://bugs.debian.org/912583
Subject: [PATCH] Fix Python index test with empty comparison

This addresses a test failure with Python 3.7 due to a change in the
StopIteration exception handling from PEP 479.

This test case has a slice index which results in an empty image. The
iteration produces a StopIteration exception which with Python 3.7 is
converted into a Run-time exception:

Traceback (most recent call last):
  File
  "/home/circleci/SimpleITK/Testing/Unit/Python/ImageIndexingTest.py",
  line 87, in test_2d
    self.assertImageNDArrayEquals(img[-4:-1:-2,-2:-1:1],nda[-2:-1:1,-4:-1:-2])
  File
  "/home/circleci/SimpleITK/Testing/Unit/Python/ImageIndexingTest.py",
  line 35, in assertImageNDArrayEquals
    for p,n in zip(img, nda.flat):
RuntimeError: generator raised StopIteration
---
 Testing/Unit/Python/ImageIndexingTest.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Testing/Unit/ImageIndexingTest.py b/Testing/Unit/Python/ImageIndexingTest.py
index 2740f6e62..c9889de7c 100644
--- a/Testing/Unit/ImageIndexingTest.py
+++ b/Testing/Unit/ImageIndexingTest.py
@@ -69,6 +69,7 @@ def test_2d(self):
         self.assertEqual(len(img[:,2:1]), 0)
         self.assertEqual(len(img[-6:0,:]), 0)
         self.assertEqual(len(img[0:0,:]), 0)
+        self.assertEqual(len(img[-4:-1:-2,-2:-1:1]), 0)
 
 
 
@@ -84,7 +85,7 @@ def test_2d(self):
 
         # some negative cases
         self.assertImageNDArrayEquals(img[-4:-1,-2:-1],nda[-2:-1,-4:-1])
-        self.assertImageNDArrayEquals(img[-4:-1:-2,-2:-1:1],nda[-2:-1:1,-4:-1:-2])
+        self.assertImageNDArrayEquals(img[-1:-4:-2,-2:-1:1],nda[-2:-1:1,-1:-4:-2])
         self.assertImageNDArrayEquals(img[::-1,:],nda[:,::-1])
 
         # check some exceptions
+1 −0
Original line number Diff line number Diff line
Fix-build-with-ITKV3_COMPATIBILITY-enabled.patch
Fix-path-created-for-output-of-4D-images-in-test.patch
Relax-the-short-image-testing-tolerance.patch
Fix-Python-index-test-with-empty-comparison.patch