Skip to content

webknossos.utils

times = {}
def time_start(identifier: str) -> None:
def time_stop(identifier: str) -> None:
def get_executor_for_args( args: Union[argparse.Namespace, NoneType], executor: Union[cluster_tools.executor_protocol.Executor, NoneType] = None) -> AbstractContextManager[cluster_tools.executor_protocol.Executor]:
F = typing.Callable[..., typing.Any]
def named_partial( func: Callable[..., Any], *args: Any, **kwargs: Any) -> Callable[..., Any]:
def wait_and_ensure_success( futures: List[concurrent.futures._base.Future], executor: cluster_tools.executor_protocol.Executor, progress_desc: Union[str, NoneType] = None) -> List[Any]:

Waits for all futures to complete and raises an exception as soon as a future resolves with an error.

def snake_to_camel_case(snake_case_name: str) -> str:
def get_chunks(arr: List[Any], chunk_size: int) -> Iterable[List[Any]]:
def time_since_epoch_in_ms() -> int:
def setup_warnings() -> None:
def setup_logging(args: argparse.Namespace) -> None:
def add_verbose_flag(parser: argparse.ArgumentParser) -> None:
def get_rich_progress() -> rich.progress.Progress:
def warn_deprecated(deprecated_item: str, alternative_item: str) -> None:
def is_fs_path(path: pathlib.Path) -> bool:
def strip_trailing_slash(path: pathlib.Path) -> pathlib.Path:
def rmtree(path: pathlib.Path) -> None:
def copytree(in_path: pathlib.Path, out_path: pathlib.Path) -> None:
class LazyReadOnlyDict(typing.Mapping[~K, ~V]):

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

LazyReadOnlyDict(entries: Dict[~K, ~C], func: Callable[[~C], ~V])
entries
func
Inherited Members
collections.abc.Mapping
get
keys
items
values
class NDArrayLike(typing.Protocol):

Base class for protocol classes.

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example::

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
NDArrayLike(*args, **kwargs)
shape: Tuple[int, ...]
ndim: int
dtype: numpy.dtype