module documentation

Common type aliases and utility functions for type checking.

Class ConfigItem Configuration schema for dynamic object instantiation. Typically used to instantiate objects stored in registries.
Class LoaderOutput No class docstring; 1/1 property, 0/3 class variable, 0/2 method documented
Function all_not_none Check whether all values in a collection are not None.
Function any_not_none Check whether at least one value in a collection is not None.
Function check_type Check whether a value has the expected type.
Type Variable T Undocumented
Type Alias Color Color type alias.
Type Alias HSV Undocumented
Type Alias Kwargs A keyword dictionary of arbitrary parameters.
Type Alias Labels Dictionary mapping task names to the annotations as C{np.ndarray}
Type Alias LoaderMultiOutput C{LoaderMultiOutput} is a tuple containing a dictionary mapping image names to C{np.ndarray} and a dictionary of task group names and their annotations as L{Labels}.
Type Alias LoaderSingleOutput C{LoaderSingleOutput} is a tuple containing a single image as a C{np.ndarray} and a dictionary of task group names and their annotations as L{Labels}.
Type Alias Params A keyword dictionary of additional parameters.
Type Alias ParamValue Undocumented
Type Alias PathType A string or a pathlib.Path object.
Type Alias PosixPathType A string or a pathlib.PurePosixPath object.
Type Alias PrimitiveType Primitive types in Python.
Type Alias RGB Undocumented
Type Alias TaskType Undocumented
def all_not_none(values: Iterable[Any]) -> bool:

Check whether all values in a collection are not None.

Examples

>>> all_not_none([1, "x", 0])
True
>>> all_not_none([1, None, 0])
False
>>> all_not_none([])
True
Parameters
values:Iterable[Any]Iterable of values to check.
Returns
boolTrue if all values are not None, otherwise False.
def any_not_none(values: Iterable[Any]) -> bool:

Check whether at least one value in a collection is not None.

Examples

>>> any_not_none([None, "x"])
True
>>> any_not_none([None, None])
False
>>> any_not_none([])
False
Parameters
values:Iterable[Any]Iterable of values to check.
Returns
boolTrue if at least one value is not None, otherwise False.
def check_type(value: Any, typ: type[T]) -> TypeGuard[T]:

Check whether a value has the expected type.

Note

This function acts as a type guard, allowing type checkers to narrow the type of a variable when the function returns True.

Examples

>>> check_type("oak", str)
True
>>> check_type("oak", int)
False
>>> check_type([1, 2, 3], list)
True
Parameters
value:AnyValue to check.
typ:type[T]Type to check against.
Returns
TypeGuard[T]True if value conforms to typ, otherwise False.
T =

Undocumented

Value
TypeVar('T')
Color: TypeAlias =

Color type alias.

Can be either a string (e.g. "red", "#FF5512"), a tuple of RGB values, or a single value (in which case it is interpreted as a grayscale value).

Value
str | int | RGB
HSV: TypeAlias =

Undocumented

Value
tuple[float, float, float]
Kwargs: TypeAlias =

A keyword dictionary of arbitrary parameters.

Value
dict[str, Any]
Labels: TypeAlias =

Dictionary mapping task names to the annotations as C{np.ndarray}

Value
dict[str, np.ndarray]
LoaderMultiOutput: TypeAlias =

C{LoaderMultiOutput} is a tuple containing a dictionary mapping image names to C{np.ndarray} and a dictionary of task group names and their annotations as L{Labels}.

Value
tuple[dict[str, np.ndarray], Labels]
LoaderSingleOutput: TypeAlias =

C{LoaderSingleOutput} is a tuple containing a single image as a C{np.ndarray} and a dictionary of task group names and their annotations as L{Labels}.

Value
tuple[np.ndarray, Labels]
Params: TypeAlias =

A keyword dictionary of additional parameters.

Usually loaded from a YAML file.

Value
dict[str, ParamValue]
ParamValue: TypeAlias =

Undocumented

Value
Mapping[PrimitiveType, ParamValue] | Sequence[ParamValue] | PrimitiveType
PathType: TypeAlias =

A string or a pathlib.Path object.

Value
str | Path
PosixPathType: TypeAlias =

A string or a pathlib.PurePosixPath object.

Value
str | PurePosixPath
PrimitiveType: TypeAlias =

Primitive types in Python.

Value
str | int | float | bool | None
RGB: TypeAlias =

Undocumented

Value
tuple[int, int, int]
TaskType: TypeAlias =

Undocumented

Value
Literal['classification',
        'boundingbox',
        'segmentation',
        'instance_segmentation',
        'keypoints',
        'array']