mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Test negate and fix a TypeError: list indices must be integers, not str
This commit is contained in:
parent
761081b1e3
commit
04f28b691e
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user