🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@timhoffm
Copy link
Member

@timhoffm timhoffm commented Dec 7, 2025

This is a numpy 2.0 regression. rgb_to_hsv((0, 1, 0)) used to work for numpy 1.x

In [1]: from matplotlib.colors import rgb_to_hsv

In [2]: rgb_to_hsv((0, 1, 0))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 rgb_to_hsv((0, 1, 0))

File ~/git/matplotlib/lib/matplotlib/colors.py:3634, in rgb_to_hsv(arr)
   3630     raise ValueError("Last dimension of input array must be 3; "
   3631                      f"shape {arr.shape} was found.")
   3633 in_shape = arr.shape
-> 3634 arr = np.array(
   3635     arr, copy=False,
   3636     dtype=np.promote_types(arr.dtype, np.float32),  # Don't work on ints.
   3637     ndmin=2,  # In case input was 1D.
   3638 )
   3640 out = np.zeros_like(arr)
   3641 arr_max = arr.max(-1)

ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

This is a numpy 2.0 regression.
@tacaswell tacaswell added this to the v3.11.0 milestone Dec 11, 2025
@tacaswell tacaswell merged commit cd66f15 into matplotlib:main Dec 11, 2025
46 of 48 checks passed
@timhoffm timhoffm deleted the mnt-rgb_to_hsv_int branch December 12, 2025 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants