Typing: relaxed type for MultiChannelExtrema

This allows for the existence of (currently not implemented)
multichannel floating point images
This commit is contained in:
Eric Soroos 2018-01-04 11:58:39 +00:00
parent 13e1902d5c
commit bebece4672
3 changed files with 3 additions and 3 deletions

View File

@ -1292,7 +1292,7 @@ class Image(object):
self.load() self.load()
if self.im.bands > 1: if self.im.bands > 1:
extrema = [] # type: Extrema extrema = []
for i in range(self.im.bands): for i in range(self.im.bands):
ex = self.im.getband(i).getextrema() # type: MultiChannelExtrema ex = self.im.getband(i).getextrema() # type: MultiChannelExtrema
extrema.append(ex) extrema.append(ex)

View File

@ -70,7 +70,7 @@ class ImagingCore:
def isblock(self) -> int: ... def isblock(self) -> int: ...
def getbbox(self) -> Optional[LURD]: ... def getbbox(self) -> Optional[LURD]: ...
def getcolors(self, maxcolors: int) -> Optional[List[Tuple[int, Color]]]: ... ################### def getcolors(self, maxcolors: int) -> Optional[List[Tuple[int, Color]]]: ... ###################
def getextrema(self) -> Tuple[float, float]: ... def getextrema(self) -> SingleChannelExtrema: ...
def getprojection(self) -> Tuple[List[int], List[int]]: ... def getprojection(self) -> Tuple[List[int], List[int]]: ...
def getband(self, band: int) -> ImagingCore: ... def getband(self, band: int) -> ImagingCore: ...
def putband(self, image: ImagingCore, band_index: int) -> None: ... def putband(self, image: ImagingCore, band_index: int) -> None: ...

View File

@ -10,7 +10,7 @@ Matrix12 = Tuple[float, float, float, float, float, float, float, float, float,
Mode = str Mode = str
SingleChannelExtrema = Union[Tuple[float, float], Tuple[int, int]] SingleChannelExtrema = Union[Tuple[float, float], Tuple[int, int]]
MultiChannelExtrema = Tuple[int, int] MultiChannelExtrema = SingleChannelExtrema # Note: currently only a Tuple[int,int]
Extrema = Union[SingleChannelExtrema, Tuple[MultiChannelExtrema, ...]] 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]]