Skip to content

Replace np.float_ with np.float64 in imshow_utils for NumPy 2 - #5890

Closed
youssef-elaasri wants to merge 2 commits into
plotly:mainfrom
youssef-elaasri:fix-numpy2-float
Closed

youssef-elaasri wants to merge 2 commits into
plotly:mainfrom
youssef-elaasri:fix-numpy2-float

Conversation

@youssef-elaasri

@youssef-elaasri youssef-elaasri commented Nov 19, 2026 •

Copy link
Copy Markdown

Link to issue

Closes #5893

import numpy as np
from plotly.express.imshow_utils import rescale_intensity
rescale_intensity(np.arange(4, dtype=np.uint8), out_range=(0, 1))
# AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.

Description of change

_output_dtype in plotly/express/imshow_utils.py returned np.float_, which NumPy 2.0 removed, so rescale_intensity(..., out_range=(min, max)) raised AttributeError. It now returns np.float64, which is the type np.float_ aliased on NumPy 1. px.imshow itself only passes out_range=np.uint8, so this affects direct callers of rescale_intensity.

Testing strategy

Added test_rescale_intensity_out_range_pair, which fails on NumPy 2 without the change and passes with it.

Additional information (optional)

Found with pipbreak, a tool I wrote that checks installed packages for APIs their dependencies removed.

Guidelines

np.float_ was removed in NumPy 2.0, so rescale_intensity(img, out_range=(a, b)) raised AttributeError.
@camdecoster

Copy link
Copy Markdown
Contributor

Thanks for the PR! Could you please open an issue for this and describe a use case where the library breaks due to this problem? Due to the volume of PRs we get, we need to validate issues and judge their impact first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rescale_intensity in imshow_utils uses np.float_, removed in NumPy 2

2 participants