scimba_torch.utils.typing_protocols

Common typing protocols to replace mypy_extensions usage.

This module provides type-safe alternatives to mypy_extensions constructs using the standard library’s typing.Protocol.

Classes

FUNC_TYPE

alias of FuncTypeCallable

FuncFuncArgsCallable(*args, **kwargs)

Protocol for higher-order functions.

FuncTypeCallable(*args, **kwargs)

Protocol for functions taking a tensor x and keyword arguments.

TYPE_FUNC_ARGS

alias of VarArgCallable

TYPE_FUNC_FUNC_ARGS

alias of FuncFuncArgsCallable

VarArgAnyCallable(*args, **kwargs)

Protocol for callable with variable arguments of any type.

VarArgCallable(*args, **kwargs)

Protocol for callable with variable torch.Tensor arguments.

class VarArgCallable(*args, **kwargs)[source]

Bases: Protocol

Protocol for callable with variable torch.Tensor arguments.

Replaces: Callable[[VarArg(torch.Tensor)], torch.Tensor]

class VarArgAnyCallable(*args, **kwargs)[source]

Bases: Protocol

Protocol for callable with variable arguments of any type.

Replaces: Callable[[VarArg(Any)], torch.Tensor]

class FuncTypeCallable(*args, **kwargs)[source]

Bases: Protocol

Protocol for functions taking a tensor x and keyword arguments.

Replaces: Callable[[Arg(torch.Tensor, “x”), KwArg(Any)], torch.Tensor]

class FuncFuncArgsCallable(*args, **kwargs)[source]

Bases: Protocol

Protocol for higher-order functions.

This function takes another function and additional args.

Replaces: Callable[[TYPE_FUNC_ARGS, VarArg(TYPE_ARGS)], torch.Tensor]

FUNC_TYPE

alias of FuncTypeCallable

TYPE_FUNC_ARGS

alias of VarArgCallable

TYPE_FUNC_FUNC_ARGS

alias of FuncFuncArgsCallable