piqa.utils#

Miscellaneous tools and general purpose components

Submodules#

piqa.utils.color

Color space conversion tools

piqa.utils.functional

General purpose tensor functionals

Functions#

assert_type

Asserts that the types, devices, shapes and values of tensors are valid with respect to some requirements.

broadcastable

Returns whether shapes are broadcastable.

set_debug

Sets and returns whether debugging is enabled or not.

Descriptions#

piqa.utils.set_debug(mode=False)#

Sets and returns whether debugging is enabled or not. If __debug__ is False, this function has not effect.

Example

>>> set_debug(False)
False
piqa.utils.broadcastable(*shapes)#

Returns whether shapes are broadcastable.

Example

>>> x = torch.rand(3, 2, 1)
>>> y = torch.rand(1, 2, 3)
>>> z = torch.rand(2, 2, 2)
>>> broadcastable(x.shape, y.shape)
True
>>> broadcastable(y.shape, z.shape)
False
piqa.utils.assert_type(*tensors, device=None, dim_range=None, n_channels=None, value_range=None)#

Asserts that the types, devices, shapes and values of tensors are valid with respect to some requirements.

Example

>>> x = torch.rand(5, 3, 256, 256)
>>> y = torch.rand(5, 3, 256, 256)
>>> assert_type(x, y, dim_range=(4, 4), n_channels=3)