Commit 1aa5a83
committed
Suppress chaining of cache lookup failure in color conversion.
Currently, something like
`scatter(range(4), range(4), c=np.arange(4).reshape((2, 2)))`
results in the following traceback:
```
Traceback (most recent call last):
File "matplotlib/lib/matplotlib/colors.py", line 173, in to_rgba
rgba = _colors_full_map.cache[c, alpha]
TypeError: unhashable type: 'numpy.ndarray'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "matplotlib/lib/matplotlib/axes/_axes.py", line 4289, in _parse_scatter_color_args
colors = mcolors.to_rgba_array(c)
File "matplotlib/lib/matplotlib/colors.py", line 284, in to_rgba_array
result[i] = to_rgba(cc, alpha)
File "matplotlib/lib/matplotlib/colors.py", line 175, in to_rgba
rgba = _to_rgba_no_colorcycle(c, alpha)
File "matplotlib/lib/matplotlib/colors.py", line 240, in _to_rgba_no_colorcycle
raise ValueError("RGBA sequence should have length 3 or 4")
ValueError: RGBA sequence should have length 3 or 4
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "matplotlib/lib/matplotlib/pyplot.py", line 2826, in scatter
None else {}), **kwargs)
File "matplotlib/lib/matplotlib/__init__.py", line 1512, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "matplotlib/lib/matplotlib/axes/_axes.py", line 4458, in scatter
get_next_color_func=self._get_patches_for_fill.get_next_color)
File "matplotlib/lib/matplotlib/axes/_axes.py", line 4302, in _parse_scatter_color_args
.format(nc=n_elem, xs=xsize, ys=ysize)
ValueError: 'c' argument has 2 elements, which is not acceptable for use with 'x' with size 4, 'y' with size 4.
```
At least the topmost failure, regarding cache lookup, is irrelevant to
the end user, so suppress it, which this commit does.
The middle traceback is mildly interesing, in case the user intended to
pass in RGBA but mis-shaped it; we may want to fold the message into the
scatter() error as well -- but that's not the object of this commit.1 parent 6013532 commit 1aa5a83
1 file changed
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| |||
0 commit comments