From 7bd6a694a7066bc34db8673c43d21fae42dd9113 Mon Sep 17 00:00:00 2001 From: Marcelo Zoccoler Date: Fri, 4 Oct 2024 09:21:39 +0200 Subject: [PATCH 1/2] Clip min eigenvalues to 0 to block negative values in sqrt This sometimes can happen with floating point representation of very small numbers --- napari_skimage_regionprops/_regionprops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napari_skimage_regionprops/_regionprops.py b/napari_skimage_regionprops/_regionprops.py index 99cc5ca..35f446e 100644 --- a/napari_skimage_regionprops/_regionprops.py +++ b/napari_skimage_regionprops/_regionprops.py @@ -193,7 +193,7 @@ def ellipsoid_axis_lengths(table): S = np.asarray([[sxx, sxy, sxz], [sxy, syy, syz], [sxz, syz, szz]]) # determine eigenvalues in descending order eigvals = np.sort(np.linalg.eigvalsh(S))[::-1] - return tuple([math.sqrt(20.0 * e) for e in eigvals]) + return tuple([math.sqrt(20.0 * np.clip(e, a_min=0, a_max=None)) for e in eigvals]) regionprops_table_all_frames = analyze_all_frames(regionprops_table) register_function(regionprops_table_all_frames, menu="Measurement tables > Regionprops of all frames (nsr)") From 862d4af306f77ff3c9705c6e36c283b14fa7d910 Mon Sep 17 00:00:00 2001 From: Marcelo Zoccoler Date: Fri, 4 Oct 2024 09:39:22 +0200 Subject: [PATCH 2/2] pin napari version for tests --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c22242f..cc60309 100644 --- a/tox.ini +++ b/tox.ini @@ -29,7 +29,7 @@ deps = pytest-cov # https://pytest-cov.readthedocs.io/en/latest/ pytest-xvfb ; sys_platform == 'linux' # you can remove these if you don't use them - napari + napari<0.5.0 magicgui pytest-qt qtpy