Skip to content

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

Open
FullStraing wants to merge 3 commits into
plotly:mainfrom
FullStraing:fix/rescale-intensity-np-float64-5893
Open

FullStraing wants to merge 3 commits into
plotly:mainfrom
FullStraing:fix/rescale-intensity-np-float64-5893

Conversation

@FullStraing

Copy link
Copy Markdown

Link to issue

Fixes #5893

Description of change

_output_dtype in plotly/express/imshow_utils.py returned np.float_ when out_range is a pair of values. NumPy 2.0 removed that alias, so rescale_intensity(..., out_range=(min, max)) raised AttributeError. It now returns np.float64, the type np.float_ aliased on NumPy 1. px.imshow itself only passes out_range=np.uint8, so this only affects direct callers of rescale_intensity.
Note: #5890 already proposed this same change, but it was closed with a request to open an issue first — #5893 is that issue. This PR re-proposes the fix against it.

Testing strategy

Added test_rescale_intensity_out_range_pair, which fails on NumPy 2 without the change and passes with it. Verified locally: the repro from #5893 raises AttributeError: np.float_ was removed in the NumPy 2.0 release on NumPy 2.5.5 before the fix, and returns [0., 1/3, 2/3, 1.] with dtype float64 after it.

Guidelines

  • I have reviewed the pull request guidelines and the Code of Conduct and confirm that this PR follows them.
  • I have added an entry to the changelog.

Added regression test for rescale_intensity function to ensure output is of type float64 and values are correct.
Updated changelog to reflect removal of Python 3.8 and 3.9 support, and fixed various issues including rescale_intensity errors and mpl_to_plotly functionality.

This branch has not been deployed

No deployments
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

1 participant