Fix Py3 range incompatibilities

This commit is contained in:
Tony S Yu
2013-10-21 23:02:51 -05:00
parent 20ad4bbca9
commit 8f506be2ea
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -388,8 +388,8 @@ class Picture(object):
def __iter__(self):
"""Iterates over all pixels in the image."""
for x in xrange(self.width):
for y in xrange(self.height):
for x in range(self.width):
for y in range(self.height):
yield self._makepixel(x, y)
def __getitem__(self, xy_index):
+2 -2
View File
@@ -67,9 +67,9 @@ def test_modify():
def test_pixel_rgb():
pic = novice.Picture.from_size((3, 3), color=(10, 10, 10))
pixel = pic[0, 0]
pixel.rgb = range(3)
pixel.rgb = np.arange(3)
assert_equal(pixel.rgb, range(3))
assert_equal(pixel.rgb, np.arange(3))
for i, channel in enumerate((pixel.red, pixel.green, pixel.blue)):
assert_equal(channel, i)