diff --git a/doc/release/contribs.py b/doc/release/contribs.py index 08a59fc9..c92ac7ca 100755 --- a/doc/release/contribs.py +++ b/doc/release/contribs.py @@ -5,16 +5,17 @@ import string import shlex if len(sys.argv) != 2: - print "Usage: ./contributors.py tag-of-previous-release" + print("Usage: ./contributors.py tag-of-previous-release") sys.exit(-1) tag = sys.argv[1] def call(cmd): - return subprocess.check_output(shlex.split(cmd)).split('\n') + print(shlex.split(cmd)) + return subprocess.check_output(shlex.split(cmd), universal_newlines=True).split('\n') tag_date = call("git show --format='%%ci' %s" % tag)[0] -print "Release %s was on %s" % (tag, tag_date) +print("Release %s was on %s" % (tag, tag_date)) merges = call("git log --since='%s' --merges --format='>>>%%B' --reverse" % tag_date) merges = [m for m in merges if m.strip()] @@ -22,27 +23,26 @@ merges = '\n'.join(merges).split('>>>') merges = [m.split('\n')[:2] for m in merges] merges = [m for m in merges if len(m) == 2 and m[1].strip()] -print "\nIt contained the following %d merges:" % len(merges) -print +print("\nIt contained the following %d merges:\n" % len(merges)) for (merge, message) in merges: if merge.startswith('Merge pull request #'): PR = ' (%s)' % merge.split()[3] else: PR = '' - print '- ' + message + PR + print('- ' + message + PR) -print "\nMade by the following committers [alphabetical by last name]:\n" +print("\nMade by the following committers [alphabetical by last name]:\n") authors = call("git log --since='%s' --format=%%aN" % tag_date) authors = [a.strip() for a in authors if a.strip()] def key(author): - author = [v for v in author.split() if v[0] in string.letters] + author = [v for v in author.split() if v[0] in string.ascii_letters] return author[-1] authors = sorted(set(authors), key=key) for a in authors: - print '-', a + print('- ' + a) diff --git a/skimage/draw/draw.py b/skimage/draw/draw.py index cbf3ced2..e61df40c 100644 --- a/skimage/draw/draw.py +++ b/skimage/draw/draw.py @@ -60,7 +60,7 @@ def ellipse(cy, cx, yradius, xradius, shape=None): cc += cx - xradius if shape is not None: - _coords_inside_image(rr, cc, shape) + return _coords_inside_image(rr, cc, shape) return rr, cc diff --git a/skimage/draw/tests/test_draw.py b/skimage/draw/tests/test_draw.py index 2d739f0f..3cb8c2a6 100644 --- a/skimage/draw/tests/test_draw.py +++ b/skimage/draw/tests/test_draw.py @@ -325,6 +325,33 @@ def test_ellipse(): assert_array_equal(img, img_) +def test_ellipse_with_shape(): + img = np.zeros((15, 15), 'uint8') + + rr, cc = ellipse(7, 7, 3, 10, shape=img.shape) + img[rr, cc] = 1 + + img_ = np.array( + [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] + ) + + assert_array_equal(img, img_) + + def test_ellipse_perimeter_dot_zeroangle(): # dot, angle == 0 img = np.zeros((30, 15), 'uint8') diff --git a/skimage/transform/_geometric.py b/skimage/transform/_geometric.py index d5b25b6d..883aa88d 100644 --- a/skimage/transform/_geometric.py +++ b/skimage/transform/_geometric.py @@ -489,11 +489,11 @@ class PiecewiseAffineTransform(GeometricTransform): class SimilarityTransform(ProjectiveTransform): """2D similarity transformation of the form:: - X = a0*x - b0*y + a1 = - = m*x*cos(rotation) + m*y*sin(rotation) + a1 + X = a0 * x - b0 * y + a1 = + = m * x * cos(rotation) - m * y * sin(rotation) + a1 - Y = b0*x + a0*y + b1 = - = m*x*sin(rotation) + m*y*cos(rotation) + b1 + Y = b0 * x + a0 * y + b1 = + = m * x * sin(rotation) + m * y * cos(rotation) + b1 where ``m`` is a zoom factor and the homogeneous transformation matrix is:: @@ -560,13 +560,13 @@ class SimilarityTransform(ProjectiveTransform): The transformation is defined as:: - X = a0*x - b0*y + a1 - Y = b0*x + a0*y + b1 + X = a0 * x - b0 * y + a1 + Y = b0 * x + a0 * y + b1 These equations can be transformed to the following form:: - 0 = a0*x - b0*y + a1 - X - 0 = b0*x + a0*y + b1 - Y + 0 = a0 * x - b0 * y + a1 - X + 0 = b0 * x + a0 * y + b1 - Y which exist for each set of corresponding points, so we have a set of N * 2 equations. The coefficients appear linearly so we can write @@ -615,8 +615,8 @@ class SimilarityTransform(ProjectiveTransform): a0, a1, b0, b1 = - V[-1, :-1] / V[-1, -1] self.params = np.array([[a0, -b0, a1], - [b0, a0, b1], - [ 0, 0, 1]]) + [b0, a0, b1], + [ 0, 0, 1]]) @property def scale(self):