| 1 | [Bug]: NumPy 1.24 deprecation warnings |
| 2 | ### Bug summary |
| 3 | |
| 4 | Starting NumPy 1.24 I observe several deprecation warnings. |
| 5 | |
| 6 | |
| 7 | ### Code for reproduction |
| 8 | |
| 9 | ```python |
| 10 | import matplotlib.pyplot as plt |
| 11 | import numpy as np |
| 12 | |
| 13 | plt.get_cmap()(np.empty((0, ), dtype=np.uint8)) |
| 14 | ``` |
| 15 | |
| 16 | |
| 17 | ### Actual outcome |
| 18 | |
| 19 | ``` |
| 20 | /usr/lib/python3.10/site-packages/matplotlib/colors.py:730: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays. The conversion of 257 to uint8 will fail in the future. |
| 21 | For the old behavior, usually: |
| 22 | np.array(value).astype(dtype)` |
| 23 | will give the desired result (the cast overflows). |
| 24 | xa[xa > self.N - 1] = self._i_over |
| 25 | /usr/lib/python3.10/site-packages/matplotlib/colors.py:731: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays. The conversion of 256 to uint8 will fail in the future. |
| 26 | For the old behavior, usually: |
| 27 | np.array(value).astype(dtype)` |
| 28 | will give the desired result (the cast overflows). |
| 29 | xa[xa < 0] = self._i_under |
| 30 | /usr/lib/python3.10/site-packages/matplotlib/colors.py:732: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays. The conversion of 258 to uint8 will fail in the future. |
| 31 | For the old behavior, usually: |
| 32 | np.array(value).astype(dtype)` |
| 33 | will give the desired result (the cast overflows). |
| 34 | xa[mask_bad] = self._i_bad |
| 35 | ``` |
| 36 | |
| 37 | ### Expected outcome |
| 38 | |
| 39 | No warnings. |
| 40 | |
| 41 | ### Additional information |
| 42 | |
| 43 | _No response_ |
| 44 | |
| 45 | ### Operating system |
| 46 | |
| 47 | ArchLinux |
| 48 | |
| 49 | ### Matplotlib Version |
| 50 | |
| 51 | 3.6.2 |
| 52 | |
| 53 | ### Matplotlib Backend |
| 54 | |
| 55 | QtAgg |
| 56 | |
| 57 | ### Python version |
| 58 | |
| 59 | Python 3.10.9 |
| 60 | |
| 61 | ### Jupyter version |
| 62 | |
| 63 | _No response_ |
| 64 | |
| 65 | ### Installation |
| 66 | |
| 67 | Linux package manager |