From e6c0c4d45c6440a17f8d50a078c98a30b8cfce19 Mon Sep 17 00:00:00 2001 From: flex-oops <94053950+FullStraing@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:47:08 -0800 Subject: [PATCH 1/3] Replace np.float_ with np.float64 in imshow_utils --- plotly/express/imshow_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/express/imshow_utils.py b/plotly/express/imshow_utils.py index 7f110ede4d0..85456ca39a0 100644 --- a/plotly/express/imshow_utils.py +++ b/plotly/express/imshow_utils.py @@ -109,7 +109,7 @@ def _output_dtype(dtype_or_range): """ if type(dtype_or_range) in [list, tuple, np.ndarray]: # pair of values: always return float. - return np.float_ + return np.float64 if isinstance(dtype_or_range, type): # already a type: return it return dtype_or_range From 1927918cf02a14f2d371684cdd74745363421f47 Mon Sep 17 00:00:00 2001 From: flex-oops <94053950+FullStraing@users.noreply.github.com> Date: Mon, 23 Nov 2026 12:04:00 -0800 Subject: [PATCH 2/3] Add regression test for rescale_intensity out_range pair Added regression test for rescale_intensity function to ensure output is of type float64 and values are correct. --- tests/test_optional/test_px/test_imshow.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_optional/test_px/test_imshow.py b/tests/test_optional/test_px/test_imshow.py index 3a0e230eb9c..d7dbf576f36 100644 --- a/tests/test_optional/test_px/test_imshow.py +++ b/tests/test_optional/test_px/test_imshow.py @@ -364,6 +364,11 @@ def test_imshow_source_dtype_zmax(dtype, contrast_rescaling): < 1 ) +def test_rescale_intensity_out_range_pair(): + # Regression test for #5893: np.float_ was removed in NumPy 2.0 + out = rescale_intensity(np.arange(4, dtype=np.uint8), out_range=(0, 1)) + assert out.dtype == np.float64 + np.testing.assert_allclose(out, [0.0, 1 / 3, 2 / 3, 1.0]) @pytest.mark.parametrize("backend", ["auto", "pypng", "pil"]) def test_imshow_backend(backend): From 3314d15f8eec6b589ef102e13f479d685fea281c Mon Sep 17 00:00:00 2001 From: flex-oops <94053950+FullStraing@users.noreply.github.com> Date: Mon, 23 Nov 2026 12:07:45 -0800 Subject: [PATCH 3/3] Add changelog entry for rescale_intensity np.float_ fix 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. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af8bac065af..e0a0a17d5c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Remove Python 3.8 and Python 3.9 support. plotly.py now requires Python 3.10 or later. [[#5883](https://github.com/plotly/plotly.py/pull/5883)] ### Fixed +- Fix `rescale_intensity` raising `AttributeError` on NumPy 2 when `out_range` is a pair, by replacing the removed `np.float_` with `np.float64` [[#5893](https://github.com/plotly/plotly.py/issues/5893)] - Fix figures in JupyterLab not redrawing when their output is updated with `update_display_data` (for example `DisplayHandle.update`), which also kept animations in other kernels on their first frame [[#5865](https://github.com/plotly/plotly.py/pull/5865)], with thanks to @AllenDowney for the contribution! - Fix `mpl_to_plotly` tick marker mirroring, axis positioning, and trace visibility for twinned and overlaid subplots (such as `twinx` and `twiny`) [[#5310](https://github.com/plotly/plotly.py/pull/5310)], with thanks to @robertoffmoura for the contribution! - Fix `mpl_to_plotly` losing matplotlib axis line colors by exporting the color of each axis's displayed spine to the plotly x and y axis `linecolor` [[#5311](https://github.com/plotly/plotly.py/pull/5311)], with thanks to @robertoffmoura for the contribution!