napari-clusters-plotter icon indicating copy to clipboard operation
napari-clusters-plotter copied to clipboard

Remove pinned numpy version when the problem is fixed (UMAP not working with Numpy>1.23.5)

Open jo-mueller opened this issue 1 year ago • 2 comments

Hi,

I was just testing some things and noticed that the UMAP was not functional in a fresh devbio-napari installation.

To reproduce

I create some sample data with this code:

import napari
from skimage import data, measure, filters
from napari_clusters_plotter._dimensionality_reduction import DimensionalityReductionWidget

image = data.human_mitosis()

labels = measure.label(image > filters.threshold_otsu(image))
features = measure.regionprops_table(labels, image, properties=('label', 'area', 'eccentricity', 'mean_intensity'))

viewer = napari.Viewer()
viewer.add_image(image, name='human mitosis')
viewer.add_labels(labels, name='human mitosis labels', features=features)


widget = DimensionalityReductionWidget(viewer)
viewer.window.add_dock_widget(widget)

napari.run()

When you select the UMAP algoithm in the dropwdown, al the features in the features list and click on run, nothing happends, whereas tSNE and PCA work. When using the debugger to step through the code, I found that this line throws an error:

result = umap(
    properties_to_reduce,
    n_neigh=n_neighbours,
    n_components=n_components,
    verbose=False,
                )

The error comes from numba: "SystemError: initialization of _internal failed without raising an exception". The error has been described here, with a possible fix being to downgrade numpy to 1.23.5.

Doing mamba install numpy==1.23.5 in my environment fixed the issue for me.

Possible fix

Pinning numpy to `numpy<1.24.0´ could do the trick, although I don't like pinning numpy. he problem has been observed in quite a few packages, though.

jo-mueller avatar Mar 17 '23 17:03 jo-mueller

Can this pin be removed now? NumPy 1.23 is not supported per SPEC-0 and is incompatible with other packages (e.g. latest zarr).

ziw-liu avatar Sep 13 '24 17:09 ziw-liu

hey @ziw-liu, thanks for catching this, I'm pretty sure that it should not cause a problem but let me test it first! It will definitely be removed in the overhaul that we are working on atm but I thinks it's a good idea to update it in the current version as well.

Cryaaa avatar Sep 17 '24 10:09 Cryaaa