Repository navigation
Replace np.float_ with np.float64 in imshow_utils for NumPy 2 - #5899
Open
FullStraing wants to merge 3 commits into
Open
FullStraing wants to merge 3 commits into
FullStraing wants to merge 3 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Fixes #5893
Description of change
_output_dtypeinplotly/express/imshow_utils.pyreturnednp.float_whenout_rangeis a pair of values. NumPy 2.0 removed that alias, sorescale_intensity(..., out_range=(min, max))raisedAttributeError. It now returnsnp.float64, the typenp.float_aliased on NumPy 1.px.imshowitself only passesout_range=np.uint8, so this only affects direct callers ofrescale_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 raisesAttributeError: np.float_ was removed in the NumPy 2.0 releaseon NumPy 2.5.5 before the fix, and returns[0., 1/3, 2/3, 1.]with dtypefloat64after it.Guidelines