| 1 | { |
| 2 | "task_id": "matplotlib__matplotlib-24970", |
| 3 | "setup_info": { |
| 4 | "repo_path": "/media/media0/yuntong/SWE-bench/testbed/matplotlib__matplotlib/setup_matplotlib__matplotlib__3.6", |
| 5 | "env_name": "setup_matplotlib__matplotlib__3.6", |
| 6 | "pre_install": [], |
| 7 | "install": "python -m pip install -e .", |
| 8 | "test_cmd": "pytest --no-header -rA --tb=no -p no:cacheprovider lib/matplotlib/tests/test_colors.py" |
| 9 | }, |
| 10 | "task_info": { |
| 11 | "instance_id": "matplotlib__matplotlib-24970", |
| 12 | "base_commit": "a3011dfd1aaa2487cce8aa7369475533133ef777", |
| 13 | "hints_text": "Thanks for the report! Unfortunately I can't reproduce this. What version of numpy are you using when the warning appears?\nSorry, forgot to mention that you need to enable the warnings during normal execution, e.g., `python -W always <file>.py`. In my case, the warnings are issued during `pytest` run which seems to activate these warnings by default.\r\n\r\nAs for the NumPy version, I'm running\r\n```console\r\n$ python -c 'import numpy; print(numpy.__version__)'\r\n1.24.0\r\n```\nThanks, I can now reproduce \ud83d\ude04 \nThe problem is that there are three more values, that are by default out of range in this case, to note specific cases:\r\nhttps://github.com/matplotlib/matplotlib/blob/8d2329ad89120410d7ef04faddba2c51db743b06/lib/matplotlib/colors.py#L673-L675\r\n(N = 256 by default)\r\n\r\nThese are then assigned to out-of-range and masked/bad values here:\r\nhttps://github.com/matplotlib/matplotlib/blob/8d2329ad89120410d7ef04faddba2c51db743b06/lib/matplotlib/colors.py#L730-L732\r\nwhich now raises a deprecation warning.\r\n\r\nI think that one way forward would be to check the type of `xa` for int/uint and in that case take modulo the maximum value for `self._i_over` etc. This is basically what happens now anyway, but we need to do it explicitly rather than relying on numpy doing it. (I cannot really see how this makes sense from a color perspective, but we will at least keep the current behavior.)\nI think this is exposing a real bug that we need to promote the input data to be bigger than uint8. What we are doing here is buildin a lookup up table, the first N entries are for for values into the actually color map and then the next 3 entries are the special cases for over/under/bad so `xa` needs to be big enough to hold `self.N + 2` as values.\nI don't know if this is a bigger bug or not, but I would like us to have fixed any deprecation warnings from dependencies before 3.7 is out (or if necessary a quick 3.7.1.)", |
| 14 | "created_at": "2023-01-13T14:23:39Z", |
| 15 | "test_patch": "diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py\n--- a/lib/matplotlib/tests/test_colors.py\n+++ b/lib/matplotlib/tests/test_colors.py\n@@ -30,6 +30,13 @@ def test_create_lookup_table(N, result):\n assert_array_almost_equal(mcolors._create_lookup_table(N, data), result)\n \n \n+@pytest.mark.parametrize(\"dtype\", [np.uint8, int, np.float16, float])\n+def test_index_dtype(dtype):\n+ # We use subtraction in the indexing, so need to verify that uint8 works\n+ cm = mpl.colormaps[\"viridis\"]\n+ assert_array_equal(cm(dtype(0)), cm(0))\n+\n+\n def test_resampled():\n \"\"\"\n GitHub issue #6025 pointed to incorrect ListedColormap.resampled;\n", |
| 16 | "repo": "matplotlib/matplotlib", |
| 17 | "problem_statement": "[Bug]: NumPy 1.24 deprecation warnings\n### Bug summary\r\n\r\nStarting NumPy 1.24 I observe several deprecation warnings.\r\n\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nplt.get_cmap()(np.empty((0, ), dtype=np.uint8))\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n```\r\n/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.\r\nFor the old behavior, usually:\r\n np.array(value).astype(dtype)`\r\nwill give the desired result (the cast overflows).\r\n xa[xa > self.N - 1] = self._i_over\r\n/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.\r\nFor the old behavior, usually:\r\n np.array(value).astype(dtype)`\r\nwill give the desired result (the cast overflows).\r\n xa[xa < 0] = self._i_under\r\n/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.\r\nFor the old behavior, usually:\r\n np.array(value).astype(dtype)`\r\nwill give the desired result (the cast overflows).\r\n xa[mask_bad] = self._i_bad\r\n```\r\n\r\n### Expected outcome\r\n\r\nNo warnings.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\nArchLinux\r\n\r\n### Matplotlib Version\r\n\r\n3.6.2\r\n\r\n### Matplotlib Backend\r\n\r\nQtAgg\r\n\r\n### Python version\r\n\r\nPython 3.10.9\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nLinux package manager\n", |
| 18 | "version": "3.6", |
| 19 | "FAIL_TO_PASS": [ |
| 20 | "lib/matplotlib/tests/test_colors.py::test_index_dtype[uint8]" |
| 21 | ], |
| 22 | "PASS_TO_PASS": [ |
| 23 | "lib/matplotlib/tests/test_colors.py::TestAsinhNorm::test_init", |
| 24 | "lib/matplotlib/tests/test_colors.py::TestAsinhNorm::test_norm", |
| 25 | "lib/matplotlib/tests/test_colors.py::test_2d_to_rgba", |
| 26 | "lib/matplotlib/tests/test_colors.py::test_BoundaryNorm", |
| 27 | "lib/matplotlib/tests/test_colors.py::test_CenteredNorm", |
| 28 | "lib/matplotlib/tests/test_colors.py::test_FuncNorm", |
| 29 | "lib/matplotlib/tests/test_colors.py::test_LogNorm", |
| 30 | "lib/matplotlib/tests/test_colors.py::test_LogNorm_inverse", |
| 31 | "lib/matplotlib/tests/test_colors.py::test_Normalize", |
| 32 | "lib/matplotlib/tests/test_colors.py::test_PowerNorm", |
| 33 | "lib/matplotlib/tests/test_colors.py::test_PowerNorm_translation_invariance", |
| 34 | "lib/matplotlib/tests/test_colors.py::test_SymLogNorm", |
| 35 | "lib/matplotlib/tests/test_colors.py::test_SymLogNorm_colorbar", |
| 36 | "lib/matplotlib/tests/test_colors.py::test_SymLogNorm_single_zero", |
| 37 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_Even", |
| 38 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_Odd", |
| 39 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_TwoSlopeNorm_VminGTVmax", |
| 40 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_VcenterGTVmax", |
| 41 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_VmaxEqualsVcenter", |
| 42 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_VminEqualsVcenter", |
| 43 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_VminGTVcenter", |
| 44 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_autoscale", |
| 45 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_autoscale_None_vmax", |
| 46 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_autoscale_None_vmin", |
| 47 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_premature_scaling", |
| 48 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_scale", |
| 49 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_scaleout_center", |
| 50 | "lib/matplotlib/tests/test_colors.py::test_TwoSlopeNorm_scaleout_center_max", |
| 51 | "lib/matplotlib/tests/test_colors.py::test_autoscale_masked", |
| 52 | "lib/matplotlib/tests/test_colors.py::test_boundarynorm_and_colorbarbase[png]", |
| 53 | "lib/matplotlib/tests/test_colors.py::test_cm_set_cmap_error", |
| 54 | "lib/matplotlib/tests/test_colors.py::test_cmap_and_norm_from_levels_and_colors2", |
| 55 | "lib/matplotlib/tests/test_colors.py::test_cmap_and_norm_from_levels_and_colors[png]", |
| 56 | "lib/matplotlib/tests/test_colors.py::test_cn", |
| 57 | "lib/matplotlib/tests/test_colors.py::test_color_names", |
| 58 | "lib/matplotlib/tests/test_colors.py::test_color_sequences", |
| 59 | "lib/matplotlib/tests/test_colors.py::test_colormap_alpha_array", |
| 60 | "lib/matplotlib/tests/test_colors.py::test_colormap_bad_data_with_alpha", |
| 61 | "lib/matplotlib/tests/test_colors.py::test_colormap_copy", |
| 62 | "lib/matplotlib/tests/test_colors.py::test_colormap_endian", |
| 63 | "lib/matplotlib/tests/test_colors.py::test_colormap_equals", |
| 64 | "lib/matplotlib/tests/test_colors.py::test_colormap_invalid", |
| 65 | "lib/matplotlib/tests/test_colors.py::test_colormap_return_types", |
| 66 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Accent]", |
| 67 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Accent_r]", |
| 68 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Blues]", |
| 69 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Blues_r]", |
| 70 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[BrBG]", |
| 71 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[BrBG_r]", |
| 72 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[BuGn]", |
| 73 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[BuGn_r]", |
| 74 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[BuPu]", |
| 75 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[BuPu_r]", |
| 76 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[CMRmap]", |
| 77 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[CMRmap_r]", |
| 78 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Dark2]", |
| 79 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Dark2_r]", |
| 80 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[GnBu]", |
| 81 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[GnBu_r]", |
| 82 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Greens]", |
| 83 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Greens_r]", |
| 84 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Greys]", |
| 85 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Greys_r]", |
| 86 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[OrRd]", |
| 87 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[OrRd_r]", |
| 88 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Oranges]", |
| 89 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Oranges_r]", |
| 90 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PRGn]", |
| 91 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PRGn_r]", |
| 92 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Paired]", |
| 93 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Paired_r]", |
| 94 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Pastel1]", |
| 95 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Pastel1_r]", |
| 96 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Pastel2]", |
| 97 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Pastel2_r]", |
| 98 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PiYG]", |
| 99 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PiYG_r]", |
| 100 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuBuGn]", |
| 101 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuBuGn_r]", |
| 102 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuBu]", |
| 103 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuBu_r]", |
| 104 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuOr]", |
| 105 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuOr_r]", |
| 106 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuRd]", |
| 107 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[PuRd_r]", |
| 108 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Purples]", |
| 109 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Purples_r]", |
| 110 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdBu]", |
| 111 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdBu_r]", |
| 112 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdGy]", |
| 113 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdGy_r]", |
| 114 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdPu]", |
| 115 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdPu_r]", |
| 116 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdYlBu]", |
| 117 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdYlBu_r]", |
| 118 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdYlGn]", |
| 119 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[RdYlGn_r]", |
| 120 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Reds]", |
| 121 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Reds_r]", |
| 122 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Set1]", |
| 123 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Set1_r]", |
| 124 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Set2]", |
| 125 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Set2_r]", |
| 126 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Set3]", |
| 127 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Set3_r]", |
| 128 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Spectral]", |
| 129 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Spectral_r]", |
| 130 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Wistia]", |
| 131 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[Wistia_r]", |
| 132 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlGnBu]", |
| 133 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlGnBu_r]", |
| 134 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlGn]", |
| 135 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlGn_r]", |
| 136 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlOrBr]", |
| 137 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlOrBr_r]", |
| 138 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlOrRd]", |
| 139 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[YlOrRd_r]", |
| 140 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[afmhot]", |
| 141 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[afmhot_r]", |
| 142 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[autumn]", |
| 143 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[autumn_r]", |
| 144 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[binary]", |
| 145 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[binary_r]", |
| 146 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[bone]", |
| 147 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[bone_r]", |
| 148 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[brg]", |
| 149 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[brg_r]", |
| 150 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[bwr]", |
| 151 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[bwr_r]", |
| 152 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[cividis]", |
| 153 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[cividis_r]", |
| 154 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[cool]", |
| 155 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[cool_r]", |
| 156 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[coolwarm]", |
| 157 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[coolwarm_r]", |
| 158 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[copper]", |
| 159 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[copper_r]", |
| 160 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[cubehelix]", |
| 161 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[cubehelix_r]", |
| 162 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[flag]", |
| 163 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[flag_r]", |
| 164 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_earth]", |
| 165 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_earth_r]", |
| 166 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_gray]", |
| 167 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_gray_r]", |
| 168 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_heat]", |
| 169 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_heat_r]", |
| 170 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_ncar]", |
| 171 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_ncar_r]", |
| 172 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_rainbow]", |
| 173 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_rainbow_r]", |
| 174 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_stern]", |
| 175 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_stern_r]", |
| 176 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_yarg]", |
| 177 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gist_yarg_r]", |
| 178 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gnuplot2]", |
| 179 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gnuplot2_r]", |
| 180 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gnuplot]", |
| 181 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gnuplot_r]", |
| 182 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gray]", |
| 183 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[gray_r]", |
| 184 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[hot]", |
| 185 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[hot_r]", |
| 186 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[hsv]", |
| 187 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[hsv_r]", |
| 188 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[inferno]", |
| 189 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[inferno_r]", |
| 190 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[jet]", |
| 191 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[jet_r]", |
| 192 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[magma]", |
| 193 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[magma_r]", |
| 194 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[nipy_spectral]", |
| 195 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[nipy_spectral_r]", |
| 196 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[ocean]", |
| 197 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[ocean_r]", |
| 198 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[pink]", |
| 199 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[pink_r]", |
| 200 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[plasma]", |
| 201 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[plasma_r]", |
| 202 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[prism]", |
| 203 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[prism_r]", |
| 204 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[rainbow]", |
| 205 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[rainbow_r]", |
| 206 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[seismic]", |
| 207 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[seismic_r]", |
| 208 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[spring]", |
| 209 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[spring_r]", |
| 210 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[summer]", |
| 211 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[summer_r]", |
| 212 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab10]", |
| 213 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab10_r]", |
| 214 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab20]", |
| 215 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab20_r]", |
| 216 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab20b]", |
| 217 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab20b_r]", |
| 218 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab20c]", |
| 219 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[tab20c_r]", |
| 220 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[terrain]", |
| 221 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[terrain_r]", |
| 222 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[turbo]", |
| 223 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[turbo_r]", |
| 224 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[twilight]", |
| 225 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[twilight_r]", |
| 226 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[twilight_shifted]", |
| 227 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[twilight_shifted_r]", |
| 228 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[viridis]", |
| 229 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[viridis_r]", |
| 230 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[winter]", |
| 231 | "lib/matplotlib/tests/test_colors.py::test_colormap_reversing[winter_r]", |
| 232 | "lib/matplotlib/tests/test_colors.py::test_colormaps_get_cmap", |
| 233 | "lib/matplotlib/tests/test_colors.py::test_conversions", |
| 234 | "lib/matplotlib/tests/test_colors.py::test_conversions_masked", |
| 235 | "lib/matplotlib/tests/test_colors.py::test_create_lookup_table[1-result2]", |
| 236 | "lib/matplotlib/tests/test_colors.py::test_create_lookup_table[2-result1]", |
| 237 | "lib/matplotlib/tests/test_colors.py::test_create_lookup_table[5-result0]", |
| 238 | "lib/matplotlib/tests/test_colors.py::test_double_register_builtin_cmap", |
| 239 | "lib/matplotlib/tests/test_colors.py::test_failed_conversions", |
| 240 | "lib/matplotlib/tests/test_colors.py::test_get_under_over_bad", |
| 241 | "lib/matplotlib/tests/test_colors.py::test_grey_gray", |
| 242 | "lib/matplotlib/tests/test_colors.py::test_has_alpha_channel", |
| 243 | "lib/matplotlib/tests/test_colors.py::test_hex_shorthand_notation", |
| 244 | "lib/matplotlib/tests/test_colors.py::test_index_dtype[float16]", |
| 245 | "lib/matplotlib/tests/test_colors.py::test_index_dtype[float]", |
| 246 | "lib/matplotlib/tests/test_colors.py::test_index_dtype[int]", |
| 247 | "lib/matplotlib/tests/test_colors.py::test_light_source_hillshading", |
| 248 | "lib/matplotlib/tests/test_colors.py::test_light_source_masked_shading", |
| 249 | "lib/matplotlib/tests/test_colors.py::test_light_source_planar_hillshading", |
| 250 | "lib/matplotlib/tests/test_colors.py::test_light_source_shading_default", |
| 251 | "lib/matplotlib/tests/test_colors.py::test_light_source_shading_empty_mask", |
| 252 | "lib/matplotlib/tests/test_colors.py::test_light_source_topo_surface[png]", |
| 253 | "lib/matplotlib/tests/test_colors.py::test_lognorm_invalid[-1-2]", |
| 254 | "lib/matplotlib/tests/test_colors.py::test_lognorm_invalid[3-1]", |
| 255 | "lib/matplotlib/tests/test_colors.py::test_make_norm_from_scale_name", |
| 256 | "lib/matplotlib/tests/test_colors.py::test_ndarray_subclass_norm", |
| 257 | "lib/matplotlib/tests/test_colors.py::test_non_mutable_get_values[bad]", |
| 258 | "lib/matplotlib/tests/test_colors.py::test_non_mutable_get_values[over]", |
| 259 | "lib/matplotlib/tests/test_colors.py::test_non_mutable_get_values[under]", |
| 260 | "lib/matplotlib/tests/test_colors.py::test_norm_callback", |
| 261 | "lib/matplotlib/tests/test_colors.py::test_norm_deepcopy", |
| 262 | "lib/matplotlib/tests/test_colors.py::test_norm_update_figs[pdf]", |
| 263 | "lib/matplotlib/tests/test_colors.py::test_norm_update_figs[png]", |
| 264 | "lib/matplotlib/tests/test_colors.py::test_pandas_iterable", |
| 265 | "lib/matplotlib/tests/test_colors.py::test_register_cmap", |
| 266 | "lib/matplotlib/tests/test_colors.py::test_repr_html", |
| 267 | "lib/matplotlib/tests/test_colors.py::test_repr_png", |
| 268 | "lib/matplotlib/tests/test_colors.py::test_resampled", |
| 269 | "lib/matplotlib/tests/test_colors.py::test_rgb_hsv_round_trip", |
| 270 | "lib/matplotlib/tests/test_colors.py::test_same_color", |
| 271 | "lib/matplotlib/tests/test_colors.py::test_scalarmappable_norm_update", |
| 272 | "lib/matplotlib/tests/test_colors.py::test_set_dict_to_rgba", |
| 273 | "lib/matplotlib/tests/test_colors.py::test_tableau_order", |
| 274 | "lib/matplotlib/tests/test_colors.py::test_to_rgba_array_alpha_array", |
| 275 | "lib/matplotlib/tests/test_colors.py::test_to_rgba_array_single_str", |
| 276 | "lib/matplotlib/tests/test_colors.py::test_unregister_builtin_cmap" |
| 277 | ], |
| 278 | "environment_setup_commit": "73909bcb408886a22e2b84581d6b9e6d9907c813", |
| 279 | "patch": "diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py\n--- a/lib/matplotlib/colors.py\n+++ b/lib/matplotlib/colors.py\n@@ -715,16 +715,17 @@ def __call__(self, X, alpha=None, bytes=False):\n if not xa.dtype.isnative:\n xa = xa.byteswap().newbyteorder() # Native byteorder is faster.\n if xa.dtype.kind == \"f\":\n- with np.errstate(invalid=\"ignore\"):\n- xa *= self.N\n- # Negative values are out of range, but astype(int) would\n- # truncate them towards zero.\n- xa[xa < 0] = -1\n- # xa == 1 (== N after multiplication) is not out of range.\n- xa[xa == self.N] = self.N - 1\n- # Avoid converting large positive values to negative integers.\n- np.clip(xa, -1, self.N, out=xa)\n- xa = xa.astype(int)\n+ xa *= self.N\n+ # Negative values are out of range, but astype(int) would\n+ # truncate them towards zero.\n+ xa[xa < 0] = -1\n+ # xa == 1 (== N after multiplication) is not out of range.\n+ xa[xa == self.N] = self.N - 1\n+ # Avoid converting large positive values to negative integers.\n+ np.clip(xa, -1, self.N, out=xa)\n+ with np.errstate(invalid=\"ignore\"):\n+ # We need this cast for unsigned ints as well as floats\n+ xa = xa.astype(int)\n # Set the over-range indices before the under-range;\n # otherwise the under-range values get converted to over-range.\n xa[xa > self.N - 1] = self._i_over\n", |
| 280 | "pr_link": "https://github.com/matplotlib/matplotlib/pull/24970" |
| 281 | } |
| 282 | } |