Skip to content

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

Open

Description

@youssef-elaasri

plotly/express/imshow_utils.py (vendored from scikit-image) still returns np.float_ in _output_dtype. NumPy 2.0 removed it, so:

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.

To be upfront about impact: px.imshow only calls it with out_range=np.uint8, so nothing breaks through the public API. I found this with a static checker, not from a user report, and I didn't find external code that calls rescale_intensity with a pair. It only affects direct callers of this helper. It's the one alias left over from #3997, which removed the other deprecated NumPy types from this file.

The fix is a one-line change (#5890). If it isn't worth the review time, feel free to close both.

Activity

  1. FullStraing commented on Nov 23, 2026

    @FullStraing

    I'll open a PR for this — the one-line fix plus a regression test.

  2. youssef-elaasri commented on Nov 23, 2026

    @youssef-elaasri
    Author

    Thanks! There's already a PR for this: plotly/plotly.py#5890 · Replace np.float_ with… (the one-line fix plus a regression test). It was closed until this issue is triaged, so it can be reopened if the maintainers decide it's worth fixing. No need for a duplicate.

  3. FullStraing commented on Nov 24, 2026

    @FullStraing

    Thanks for flagging #5890 — I saw it before opening this one. #5890 was closed with a request to open an issue first, and #5893 is that issue, so #5899 re-proposes the same fix against it (same one-line change and the same regression test, plus a changelog entry). Happy to close #5899 if maintainers would rather reopen #5890 — just let me know which one you prefer.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions