mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #7623 from hugovk/cleanup-imagemath-inline-isinstance
ImageMath: Inline `isinstance` check
This commit is contained in:
commit
67890b221e
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user