napari.types

Classes

ArrayBase

alias of numpy.ndarray

Path

PurePath subclass that can make system calls.

SampleDict

TracebackType

alias of types.TracebackType

TypedDict

A simple typed name space.

partial

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

Functions

napari.types.ImageData(x)
napari.types.LabelsData(x)
napari.types.LayerDataTuple(x)
napari.types.NewType(name, tp)[source]

NewType creates simple unique types with almost zero runtime overhead. NewType(name, tp) is considered a subtype of tp by static type checkers. At runtime, NewType(name, tp) returns a dummy function that simply returns its argument. Usage:

UserId = NewType('UserId', int)

def name_by_id(user_id: UserId) -> str:
    ...

UserId('user')          # Fails type check

name_by_id(42)          # Fails type check
name_by_id(UserId(42))  # OK

num = UserId(5) + 1     # type: int
napari.types.PointsData(x)
napari.types.ShapesData(x)
napari.types.SurfaceData(x)
napari.types.TracksData(x)
napari.types.VectorsData(x)
napari.types.get_args(tp)[source]

Get type arguments with all substitutions performed.

For unions, basic simplifications used by Union constructor are performed. Examples:

get_args(Dict[str, int]) == (str, int)
get_args(int) == ()
get_args(Union[int, Union[T, int], str][int]) == (int, str)
get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
get_args(Callable[[], T][int]) == ([], int)
napari.types.image_reader_to_layerdata_reader(func: Callable[[Union[str, Sequence[str]]], Union[numpy.ndarray, dask.array.Array, zarr.Array]]) Callable[[Union[str, Sequence[str]]], List[Union[Tuple[Any], Tuple[Any, Dict], Tuple[Any, Dict, str]]]][source]

Convert a PathLike -> ArrayLike function to a PathLike -> LayerData.

Parameters

func (Callable[[PathLike], ArrayLike]) – A function that accepts a string or list of strings, and returns an ArrayLike.

Returns

reader_function – A function that accepts a string or list of strings, and returns data as a list of LayerData: List[Tuple[ArrayLike]]

Return type

Callable[[PathLike], List[LayerData]]

napari.types.wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',))[source]

Decorator factory to apply update_wrapper() to a wrapper function

Returns a decorator that invokes update_wrapper() with the decorated function as the wrapper argument and the arguments to wraps() as the remaining arguments. Default arguments are as for update_wrapper(). This is a convenience function to simplify applying partial() to update_wrapper().