Test negate and fix a TypeError: list indices must be integers, not str

This commit is contained in:
hugovk 2017-05-28 23:02:06 +03:00 committed by Hugo
parent 761081b1e3
commit 04f28b691e
2 changed files with 20 additions and 4 deletions

View File

@ -123,7 +123,7 @@ class LutBuilder(object):
.replace('0', 'Z')
.replace('1', '0')
.replace('Z', '1'))
res = '%d' % (1-int(res))
res = 1-int(res)
patterns.append((pattern, res))
return patterns
@ -152,8 +152,8 @@ class LutBuilder(object):
patterns += self._pattern_permute(pattern, options, result)
# # Debugging
# for p,r in patterns:
# print(p,r)
# for p, r in patterns:
# print(p, r)
# print('--')
# compile the patterns into regular expressions for speed

View File

@ -184,7 +184,6 @@ class MorphTests(PillowTestCase):
self.assertEqual(count, 7)
self.assert_img_equal_img_string(Aout,
"""
.......
.......
..1.1..
@ -194,6 +193,23 @@ class MorphTests(PillowTestCase):
.......
""")
def test_negate(self):
# Test 'N' for negate
mop = ImageMorph.MorphOp(patterns=['1:(... ... ...)->0',
'N:(00. 01. ...)->1'])
count, Aout = mop.apply(self.A)
self.assertEqual(count, 8)
self.assert_img_equal_img_string(Aout,
"""
.......
.......
..1....
.......
.......
.......
.......
""")
def test_non_binary_images(self):
im = hopper('RGB')
mop = ImageMorph.MorphOp(op_name="erosion8")