Skip to content

Commit

Permalink
fix tracks instantiation with floating point time values (napari#3909)
Browse files Browse the repository at this point in the history
* Bump vispy (napari#3494)

* removing stuff

* get rid of vendored

* working without vendored mesh

* remove vendored mesh file

* update vispy minimum requirement to 0.7.0

* only fire shading change event in 3d

* working 3d...

* simple wins

* temporary vispy-testing addition

* force vispy version, hopefully

* vispy 0.9.1

* "fix" attenuation test

* vispy 0.9.2, bugfix

* fix dimensionality issue with mesh shading filters

* rever unnecessary changes

* remove useless file, fix tiled image color transform

* readd vendored image to fix merge

* vispy 0.9.3, several bug fixes

* Empty commit to trigger CI

* trigger CI

* fix deprecation errors with markers

* switch to GPU textures

* fix more deprecation errors

* Revert "switch to GPU textures"

This reverts commit 21bb2bc.

* latest vispy

* trigger ci

* fix point symbol

Co-authored-by: Alister Burt <[email protected]>
Co-authored-by: Juan Nunez-Iglesias <[email protected]>
Co-authored-by: Matthias Bussonnier <[email protected]>

* Add setter for modifying multiple dims.range elements (napari#3677)

* Add dims._set_ranges for setting multiple range elements simultaneously

Calling the current set_range over all axes in a loop results in unnecessarily
high number of events to be emitted. It is better in this case to update
dims.range in a single call.

* merge _set_dims into existing set_dims public API

set last_used to minimum axis that was modified

* remove update to last_used from dims.set_range

* Force layer name to be string (napari#3699)

* remove slows (napari#3703)

* Support python 3.10 (napari#3702)

* py310 tests

* pin torch test version

* add 3.10 to setupcfg

* gate tensorstore

* cleaner

* switch to pyqt5

* Add sequence support to more Dims setters (napari#3709)

* Add sequence support to more dims setters

dims.set_point, dims.set_current_step, dims.set_axis_label are updated
to allow assigning to any number of axis as was done previously for
set_range

removed updating of last_used from set_current_step

* improve test coverage

* Fix: change tuple->list so list comparison works

* Add support for property.setters to EventedModel (napari#3711)

* add support for prop setters

* auto-detect dependencies

* whoops.  fix test

* use fget for dependency detection

* remove code step (napari#3717)

* Fix link to myst-parser docs (napari#3716)

* Transform mode for image layer (napari#3611)

* Initial working prototype

* Connected key bindings

* Better nD support

* Fix some tests

* Remove QT buttons

* Color vertices

* Some polish

* Fix test failure

* replace_slice function

* Keyboard shortcuts and mapping to layer affine

* Preserve out-of-display transform

* More tests

* Enable in label layer

* fix even ordering

* Support in points and shapes

* Update napari/utils/transforms/transforms.py

Co-authored-by: Andy Sweet <[email protected]>

* Update napari/components/_interaction_box_mouse_bindings.py

Co-authored-by: Andy Sweet <[email protected]>

* Update napari/components/_interaction_box_mouse_bindings.py

Co-authored-by: Andy Sweet <[email protected]>

* Cleaner code for tests

* Update napari/components/_interaction_box_mouse_bindings.py

Co-authored-by: Andy Sweet <[email protected]>

* Minor revisions

* Update napari/components/_interaction_box_mouse_bindings.py

Co-authored-by: Andy Sweet <[email protected]>

* Update napari/utils/transforms/transforms.py

Co-authored-by: Andy Sweet <[email protected]>

* Update napari/utils/transforms/transforms.py

Co-authored-by: Andy Sweet <[email protected]>

* Minor revisions

* Remove replace_slice from base transform

* Fixed issues with napari#3494

* Clarification in tests

Co-authored-by: Johannes Elferich <[email protected]>
Co-authored-by: Talley Lambert <[email protected]>
Co-authored-by: Andy Sweet <[email protected]>

* Fixes several sphinx warnings. (napari#3706)

* Add a button linking to the plugin homepage in the plugin installer dialog (napari#3712)

* add a button with link to online docs

* simplified code, hide help-button in case project url is unknown

* removed dead code path

* fixed black

* more efficient computation of displayed dimension order (napari#3714)

* more efficient computation of displayed dimension order

* avoid potential mismatch between dims_displayed and ndisplay

* delay import from components.dims in base.py

* remove slow decorator (napari#3705)

* mac matrix

* remove timeout on image atten

* no slow

* remove timeout

* remove timeout

* add back for dask tests

* add back timeout to layer utils

* add back xarray

* updates

* add comments

* Use GPU scaled textures (fix NaN) (napari#3701)

* fix clim calculation

* use GPU textures

* ugly, probably wrong, but kinda works

* use float32, add test

* test more dtypes

* fix test

* only use nanmax/nanmin if necessary

* increase relative tolerance cause float16 can sometimes fail when close to max value

* fix broken tests with nan and inf

* use correct array specs

* account for all-nan arrays

* fix test for py37

* fix version check

* nan to num

* more all

* Test some typing on PR (napari#3722)

* test some typing on PR

* remove name

* Add `napari/plugins` and `utils/context` to typechecks (napari#3728)

* plugins

* update makefile

* not sure if daemon worked on CI

* fix makefile

* add context too

* Update .gitignore

* Update napari/plugins/_builtins.py

* add failing test

* fix bug

* add failing test

* fix bug

* round time before casting to int

* remove test as float timestamps are no longer 'malformed'

Co-authored-by: Lorenzo Gaifas <[email protected]>
Co-authored-by: Juan Nunez-Iglesias <[email protected]>
Co-authored-by: Matthias Bussonnier <[email protected]>
Co-authored-by: Gregory R. Lee <[email protected]>
Co-authored-by: Grzegorz Bokota <[email protected]>
Co-authored-by: Talley Lambert <[email protected]>
Co-authored-by: Genevieve Buckley <[email protected]>
Co-authored-by: Johannes Elferich <[email protected]>
Co-authored-by: Johannes Elferich <[email protected]>
Co-authored-by: Andy Sweet <[email protected]>
Co-authored-by: Melissa Weber Mendonça <[email protected]>
Co-authored-by: Robert Haase <[email protected]>
  • Loading branch information
13 people authored Jan 13, 2022
1 parent 2c1d811 commit dbf2cc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions napari/layers/tracks/_tests/test_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ def test_malformed_id():
Tracks(data)


def test_malformed_timestamps():
"""Test for malformed track timestamps."""
data = np.random.random((100, 4))
data[:, 0] = 0
with pytest.raises(ValueError):
Tracks(data)


def test_malformed_graph():
"""Test for malformed graph."""
data = np.zeros((100, 4))
Expand All @@ -180,3 +172,13 @@ def test_malformed_graph():
graph = {1: [0], 2: [33]}
with pytest.raises(ValueError):
Tracks(data, graph=graph)


def test_tracks_float_time_index():
"""Test Tracks layer instantiation with floating point time values"""
coords = np.random.normal(loc=50, size=(100, 2))
time = np.random.normal(loc=50, size=(100, 1))
track_id = np.zeros((100, 1))
track_id[50:] = 1
data = np.concatenate((track_id, time, coords), axis=1)
Tracks(data)
5 changes: 3 additions & 2 deletions napari/layers/tracks/_track_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ def data(self, data: Union[list, np.ndarray]):
# here to make sure that we align with the napari dims index which
# will be an integer - however, the time index does not necessarily
# need to be an int, and the shader will render correctly.
frames = list(set(self._points[:, 0].astype(np.uint).tolist()))
time = np.round(self._points[:, 0]).astype(np.uint)
frames = list(set(time.tolist()))
self._points_lookup = {}
for f in frames:
idx = np.where(self._points[:, 0] == f)[0]
idx = np.where(time == f)[0]
self._points_lookup[f] = slice(min(idx), max(idx) + 1, 1)

# make a second lookup table using a sparse matrix to convert track id
Expand Down

0 comments on commit dbf2cc8

Please sign in to comment.