napari.types

Classes

ArrayBase

alias of numpy.ndarray

TracebackType

alias of traceback

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.image_reader_to_layerdata_reader(func)[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().