def test_vectorData_datatype1(): """ test data of coord-like shape :return: """ with app_context(): # create the viewer and window viewer = ViewerApp() N = 10 pos = np.zeros(shape=(N, 4), dtype=np.float32) try: viewer.add_vectors(pos) except Exception as ex: print("exception thrown when creating coord-like vector layer: "+str(ex))
def test_vectorData_image_assignment(self): """ test replacing vector data after layer construction :return: """ with app_context(): # create the viewer and window viewer = ViewerApp() N = 10 pos = np.zeros(shape=(N, 4), dtype=np.float32) pos2 = np.zeros(shape=(N, N, 2), dtype=np.float32) try: layer = viewer.add_vectors(pos) layer.vectors = pos2 except Exception as ex: print("exception thrown when : "+str(ex))
def test_vectorData_datatype_notimpl2(self): """ test data of vispy-coordinate shape (not allowed) :return: """ with app_context(): # create the viewer and window viewer = ViewerApp() N = 10 pos = np.zeros(shape=(N, 2), dtype=np.float32) try: viewer.add_vectors(pos) except InvalidDataFormatError: print('invalid data format') except Exception as ex: print("exception thrown when creating not implemented vector layer: "+str(ex))
def test_vectorData_datatype_notimpl(): """ test data of improper shape :return: """ with app_context(): # create the viewer and window viewer = ViewerApp() N = 10 M = 5 pos = np.zeros(shape=(N, M, 4), dtype=np.float32) try: viewer.add_vectors(pos) except InvalidDataFormatError: print('invalid data format') except Exception as ex: print("exception thrown when creating not implemented vector layer: "+str(ex))
""" Display one 4-D image layer using the add_image API """ import dask.array as da import zarr import numpy as np from skimage import data from napari import ViewerApp from napari.util import app_context with app_context(): data = zarr.zeros((102_000, 200, 210), chunks=(100, 200, 210)) data[53_000:53_100, 100:110, 110:120] = 1 array = da.from_zarr(data) print(array.shape) viewer = ViewerApp(array, clim_range=[0, 1], multichannel=False)