diff --git a/README.md b/README.md index 0be6bbf..192df1d 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Once it is installed, you can use the `phomo` command. It would go something like: ```sh -$ phomo master.png tile_directory -S 20 20 -o mosaic.png +phomo master.png tile_directory -S 20 20 -o mosaic.png ``` If in doubt see the help: diff --git a/phomo/master.py b/phomo/master.py index 2244ab6..b32e7a8 100644 --- a/phomo/master.py +++ b/phomo/master.py @@ -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: diff --git a/phomo/metrics.py b/phomo/metrics.py index abdb29a..8d6dfb5 100644 --- a/phomo/metrics.py +++ b/phomo/metrics.py @@ -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. diff --git a/phomo/mosaic.py b/phomo/mosaic.py index 1ddaaaa..1c7f866 100644 --- a/phomo/mosaic.py +++ b/phomo/mosaic.py @@ -35,6 +35,8 @@ def __init__( Examples: Building a mosaic. + >>> pool = Pool.from_dir("tiles") + >>> master = Master.from_file("master.png") >>> Mosaic(master, pool, n_appearances=1).build() """ self._log = logging.getLogger(__name__) diff --git a/phomo/palette.py b/phomo/palette.py index 9195835..8a839ae 100644 --- a/phomo/palette.py +++ b/phomo/palette.py @@ -1,6 +1,7 @@ from typing import Tuple import matplotlib.pyplot as plt +from matplotlib.figure import Figure import numpy as np @@ -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: diff --git a/phomo/pool.py b/phomo/pool.py index 0d66ce6..3ebb66f 100644 --- a/phomo/pool.py +++ b/phomo/pool.py @@ -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 diff --git a/phomo/utils.py b/phomo/utils.py index c6b8435..8bebfc4 100644 --- a/phomo/utils.py +++ b/phomo/utils.py @@ -10,7 +10,7 @@ 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. @@ -18,7 +18,9 @@ def rainbow_of_squares( 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): @@ -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.