Skip to content

conv

Utility functions for convolutional operations.

Functions:

Name Description
is_pair

Return whether the input tuple is a pair of items.

pair

Convert a single int or a sequence of two int values to a 2-ple of int representing the side lengths of a 2D patch.

is_pair

is_pair(
    _tuple: tuple[TupleItemT, ...],
) -> TypeGuard[tuple[TupleItemT, TupleItemT]]

Return whether the input tuple is a pair of items.

Returns:

Type Description
TypeGuard[tuple[TupleItemT, TupleItemT]]

Whether the input tuple is a pair of items.

pair

pair(
    patch_size: int | tuple[int, int] | Sequence[int],
) -> tuple[int, int]

Convert a single int or a sequence of two int values to a 2-ple of int representing the side lengths of a 2D patch.

If a single int is given, a square patch is returned.

Parameters:

Name Type Description Default

patch_size

int | tuple[int, int] | Sequence[int]

The patch size to convert.

required

Returns:

Type Description
tuple[int, int]

A pair of integers representing the patch size.

Raises:

Type Description
ValueError

If the patch size is not a single int or a sequence of two int values.

ValueError

If any of patch size side lengths are not positive.