Merge pull request #7623 from hugovk/cleanup-imagemath-inline-isinstance

ImageMath: Inline `isinstance` check
This commit is contained in:
Andrew Murray 2023-12-19 08:43:21 +11:00 committed by GitHub
commit 67890b221e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,10 +20,6 @@ import builtins
from . import Image, _imagingmath
def _isconstant(v):
return isinstance(v, (int, float))
class _Operand:
"""Wraps an image operand, providing standard operators"""
@ -43,7 +39,7 @@ class _Operand:
raise ValueError(msg)
else:
# argument was a constant
if _isconstant(im1) and self.im.mode in ("1", "L", "I"):
if isinstance(im1, (int, float)) and self.im.mode in ("1", "L", "I"):
return Image.new("I", self.im.size, im1)
else:
return Image.new("F", self.im.size, im1)