Skip to content

Commit

Permalink
fix: docstring cleanup & minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
loiccoyle committed Sep 22, 2023
1 parent 5dbba55 commit 6bfcbb4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion phomo/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def from_file(
Args:
master_image_file: path to image file.
crop_ratio: width to height ratio to crop the master image to. 1 results in a square image.
image_size: resize the image to the provided size, width followed by height.
img_size: resize the image to the provided size, width followed by height.
convert: convert the image to the provided mode. See PIL Modes.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion phomo/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def greyscale(

@register_metric
def norm(master_chunk: np.ndarray, tile_arrays: np.ndarray, **kwargs) -> np.ndarray:
"""``np.linalg.norm`` distance metric.
"""Distance metric using ``np.linalg.norm``.
Quick distance metric in RGB space.
Expand Down
3 changes: 2 additions & 1 deletion phomo/palette.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Tuple

import matplotlib.pyplot as plt
from matplotlib.figure import Figure
import numpy as np


Expand Down Expand Up @@ -45,7 +46,7 @@ def _cdfs(frequencies: np.ndarray) -> np.ndarray:
cdfs /= cdfs[-1]
return cdfs

def plot(self, log: bool = False) -> Tuple[plt.Figure, np.ndarray]:
def plot(self, log: bool = False) -> Tuple[Figure, np.ndarray]:
"""Plot the colour distribution.
Args:
Expand Down
2 changes: 1 addition & 1 deletion phomo/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(
self,
arrays: Sequence[np.ndarray],
) -> None:
"""A Pool of images tiles.
"""A Pool of tile images.
Args:
arrays: list of arrays containing the image pixel values. Should
Expand Down
9 changes: 6 additions & 3 deletions phomo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
def rainbow_of_squares(
target_dir: Path, size: Tuple[int, int] = (10, 10), range_params=(0, 256, 15)
) -> None:
"""Generate 5832 small solid-color tiles for experimentation and testing.
"""Generate 5832 solid-color tiles for experimentation and testing.
Args:
target_dir: direcotry in which to place the rainbow tiles.
size: size of the images, width followed by height.
range_params: Passed to ``range()`` to stride through each color channel.
"""
target_dir.mkdir(exist_ok=True)
with tqdm(total=3 * len(range(*range_params))) as pbar:
with tqdm(
total=3 * len(range(*range_params)), desc="Generating color tiles"
) as pbar:
canvas = np.ones((*size[::-1], 3))
for r in range(*range_params):
for g in range(*range_params):
Expand All @@ -36,7 +38,8 @@ def crop_to_ratio(image: Image.Image, ratio: float = 1) -> Image.Image:
Args:
image: PIL.Image to crop.
ratio: width to height ratio to which to crop the image. Use 1 to obtain a square image.
ratio: width to height ratio to which to crop the image. Use 1 to obtain a
square image.
Returns:
Cropped PIL.Image.
Expand Down

0 comments on commit 6bfcbb4

Please sign in to comment.