mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-26 07:04:45 +03:00
Typing: Additional extrema types
This commit is contained in:
parent
2ce902a7f6
commit
4d06d70613
|
@ -1292,16 +1292,10 @@ class Image(object):
|
||||||
|
|
||||||
self.load()
|
self.load()
|
||||||
if self.im.bands > 1:
|
if self.im.bands > 1:
|
||||||
extrema = [] # type: List[Tuple[int,int]]
|
extrema = [] # type: Extrema
|
||||||
# UNDONE typing:
|
|
||||||
# We know that the extrema here is List[Tuple[int,int]]
|
|
||||||
# but the method sig of getextrema mentions a float, but
|
|
||||||
# we know that if it's a multiband image, it's got to be
|
|
||||||
# int. Single band images could be either.
|
|
||||||
# We could cast, but that's not going to work with py27 or
|
|
||||||
# py34
|
|
||||||
for i in range(self.im.bands):
|
for i in range(self.im.bands):
|
||||||
extrema.append(self.im.getband(i).getextrema()) # type: ignore
|
ex = self.im.getband(i).getextrema() # type: MultiChannelExtrema
|
||||||
|
extrema.append(ex)
|
||||||
return tuple(extrema)
|
return tuple(extrema)
|
||||||
return self.im.getextrema()
|
return self.im.getextrema()
|
||||||
|
|
||||||
|
@ -1363,7 +1357,7 @@ class Image(object):
|
||||||
return [i8(c) for c in x], [i8(c) for c in y]
|
return [i8(c) for c in x], [i8(c) for c in y]
|
||||||
|
|
||||||
def histogram(self, mask=None, extrema=None):
|
def histogram(self, mask=None, extrema=None):
|
||||||
# type: (Optional[Image], Optional[Extrema]) -> List[int]
|
# type: (Optional[Image], Optional[SingleChannelExtrema]) -> List[int]
|
||||||
"""
|
"""
|
||||||
Returns a histogram for the image. The histogram is returned as
|
Returns a histogram for the image. The histogram is returned as
|
||||||
a list of pixel counts, one for each pixel value in the source
|
a list of pixel counts, one for each pixel value in the source
|
||||||
|
|
|
@ -8,5 +8,9 @@ Size = XY # NOTE: All XY aliases will be interchangeable
|
||||||
Matrix4 = Tuple[float, float, float, float]
|
Matrix4 = Tuple[float, float, float, float]
|
||||||
Matrix12 = Tuple[float, float, float, float, float, float, float, float, float, float, float, float]
|
Matrix12 = Tuple[float, float, float, float, float, float, float, float, float, float, float, float]
|
||||||
Mode = str
|
Mode = str
|
||||||
Extrema = Union[Tuple[float, float], Tuple[int, int], Tuple[Tuple[int, int], ...]]
|
|
||||||
|
SingleChannelExtrema = Union[Tuple[float, float], Tuple[int, int]]
|
||||||
|
MultiChannelExtrema = Tuple[int, int]
|
||||||
|
Extrema = Union[SingleChannelExtrema, Tuple[MultiChannelExtrema, ...]]
|
||||||
|
|
||||||
Color = Union[int, float, Tuple[int, int], Tuple[int, int, int], Tuple[int, int, int, int]]
|
Color = Union[int, float, Tuple[int, int], Tuple[int, int, int], Tuple[int, int, int, int]]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user