Skip to content

Commit 67890b2

Browse files
authored
Merge pull request #7623 from hugovk/cleanup-imagemath-inline-isinstance
ImageMath: Inline `isinstance` check
2 parents a835bfb + 368c05c commit 67890b2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/PIL/ImageMath.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
from . import Image, _imagingmath
2121

2222

23-
def _isconstant(v):
24-
return isinstance(v, (int, float))
25-
26-
2723
class _Operand:
2824
"""Wraps an image operand, providing standard operators"""
2925

@@ -43,7 +39,7 @@ def __fixup(self, im1):
4339
raise ValueError(msg)
4440
else:
4541
# argument was a constant
46-
if _isconstant(im1) and self.im.mode in ("1", "L", "I"):
42+
if isinstance(im1, (int, float)) and self.im.mode in ("1", "L", "I"):
4743
return Image.new("I", self.im.size, im1)
4844
else:
4945
return Image.new("F", self.im.size, im1)

0 commit comments

Comments
 (0)