Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""
Display many points layers
"""
import numpy as np
import napari
from time import time
data = []
for i in range(50):
@sofroniewn
sofroniewn / extent.py
Created October 24, 2020 01:53
extent object for napari
import numpy as np
from ..utils.events import EmitterGroup
class Extent:
"""Extent object holding minimum and maximum values of data.
Parameters
----------
@sofroniewn
sofroniewn / TransformChain.py
Created March 4, 2020 23:40
holder for TransformChain
class TransformChain(ListModel, Transform):
def __init__(self, transforms=[]):
super().__init__(
basetype=Transform,
iterable=transforms,
lookup={str: lambda q, e: q == e.name},
)
def __call__(self, coords):
return tz.pipe(coords, *self)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def generate_3D_path_meshes_2D(path, p=(0, 0, 1)):
"""Generates list of mesh vertices and triangles from a path
Parameters
----------
path : (N, D) array
Vertices specifying the path where D is 2 or 3.
p : 3-tuple, optional
orthogonal vector for segment calculation in 3D.
def _get_viewer_thumbnail(self):
"""Creat an overall thumbnail based on the layer thumbnails."""
thumbnail = np.zeros(layers.Layer._thumbnail_shape, dtype=np.uint8)
for layer in self.layers[::-1]:
if layer.blending == 'translucent':
f_dest = thumbnail[..., 3][..., None] / 255
f_source = 1 - layer.thumbnail[..., 3][..., None] / 255
elif layer.blending == 'additive':
f_dest = thumbnail[..., 3][..., None] / 255
@sofroniewn
sofroniewn / range_slider_tests.py
Created April 20, 2019 03:21
Tests for range slider
"""
Interactive test for range slider.
"""
# starts the QT event loop
from napari._qt.range_slider.range_slider import QVRangeSlider
from napari.util import app_context
with app_context():
@sofroniewn
sofroniewn / qtviewer_tests.py
Created April 20, 2019 03:20
Tests for qtviewer
from skimage import data
from skimage.color import rgb2gray
from napari import Viewer
from napari.util import app_context
# THIS WILL NOT WORK UNTIL THERE IS SEPARATION BETWEEN MODEL AND VIEW!
def test_dims_and_ranges():
@sofroniewn
sofroniewn / qtdims_tests.py
Created April 20, 2019 03:18
Tests for qtdims model
# This is in interactive test
from time import sleep
import threading
from napari.components import Dims
from napari.components._dims._constants import DimsMode
from napari.components._dims.view import QtDims
from napari.util import app_context