Skip to content

NumPy 2.0+ Compatibility Issue with Scrublet (ptp function) #65

Description

@rural-lady

I ran into a small issue while using Scrublet with NumPy 2.0 and above. When I tried running this:
scrub.plot_embedding('UMAP', order_points=True)
I got the following error:
AttributeError: ptp was removed from the ndarray class in NumPy 2.0. Use np.ptp(arr, ...) instead.
The problem is that in NumPy 2.0, they removed the ptp() method from the ndarray class, and now it should be called like np.ptp(arr) instead.

Solution:
If you want to fix this, you can update scrublet.py (lines 530 and 531) like this:

Change this:

xl = (x.min() - x.ptp() * .05, x.max() + x.ptp() * 0.05)
yl = (y.min() - y.ptp() * .05, y.max() + y.ptp() * 0.05)

To this:

xl = (x.min() - np.ptp(x) * .05, x.max() + np.ptp(x) * 0.05)
yl = (y.min() - np.ptp(y) * .05, y.max() + np.ptp(y) * 0.05)

How to do it:
First, find where Scrublet is installed by running:
pip show scrublet
This will show you a path like:
/miniconda3/envs/py37/lib/python3.7/site-packages
Go to the folder where scrublet.py is located and open it to edit.
This fix should solve the problem, and make Scrublet compatible with NumPy 2.0+.
Hope this helps! Thanks for the awesome work on Scrublet, and I’m excited to see future updates.

Cheers,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions