Skip to content

Commit

Permalink
Fix misc typing in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
qTipTip committed Jan 27, 2025
1 parent b5b52c7 commit 1a0b0a2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Pylette/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def _get_min_max(self) -> None:
"""
Calculates the minimum and maximum values for each color channel in the ColorBox.
"""
self.min_channel: NDArray[np.uint8, (3,)] = np.min(self.colors, axis=0)
self.max_channel: NDArray[np.uint8, (3,)] = np.max(self.colors, axis=0)
self.min_channel: NDArray[np.uint8] = np.min(self.colors, axis=0)
self.max_channel: NDArray[np.uint8] = np.max(self.colors, axis=0)

def __lt__(self, other: "ColorBox") -> bool:
"""
Expand All @@ -36,10 +36,10 @@ def __lt__(self, other: "ColorBox") -> bool:
Returns:
bool: True if the volume of this ColorBox is less than the volume of the other ColorBox, False otherwise.
"""
return self.size < other.size
return bool(self.size < other.size)

@property
def size(self) -> np.uint64:
def size(self) -> int:
"""
Returns the volume of the ColorBox.
Expand All @@ -55,12 +55,12 @@ def _get_dominant_channel(self) -> int:
Returns:
int: The index of the dominant color channel.
"""
diff: NDArray[np.uint8, (3,)] = self.max_channel - self.min_channel
diff: NDArray[np.uint8] = self.max_channel - self.min_channel
dominant_channel = np.argmax(diff)
return dominant_channel
return int(dominant_channel)

@property
def average(self) -> np.ndarray:
def average(self) -> NDArray[np.uint8]:
"""
Calculates the average color contained in the ColorBox.
Expand All @@ -80,7 +80,7 @@ def volume(self) -> int:
Returns:
int: The volume of the ColorBox.
"""
diff: NDArray[np.uint8, (3,)] = self.max_channel - self.min_channel
diff: NDArray[np.uint8] = self.max_channel - self.min_channel
return np.prod(diff).item()

def split(self) -> list["ColorBox"]:
Expand Down

0 comments on commit 1a0b0a2

Please sign in to comment.