|
| 1 | +import contextlib |
1 | 2 | from collections import namedtuple
|
2 | 3 | import datetime
|
3 | 4 | from decimal import Decimal
|
@@ -2639,9 +2640,14 @@ def get_next_color():
|
2639 | 2640 | }
|
2640 | 2641 |
|
2641 | 2642 | if re_key is None:
|
2642 |
| - mpl.axes.Axes._parse_scatter_color_args( |
2643 |
| - c=c_case, edgecolors="black", kwargs={}, xsize=xsize, |
2644 |
| - get_next_color_func=get_next_color) |
| 2643 | + may_warn_context = ( |
| 2644 | + pytest.warns(match="argument looks like a single numeric RGB") |
| 2645 | + if isinstance(c_case, list) and len(c_case) == 3 |
| 2646 | + else contextlib.nullcontext()) |
| 2647 | + with may_warn_context: |
| 2648 | + mpl.axes.Axes._parse_scatter_color_args( |
| 2649 | + c=c_case, edgecolors="black", kwargs={}, xsize=xsize, |
| 2650 | + get_next_color_func=get_next_color) |
2645 | 2651 | else:
|
2646 | 2652 | with pytest.raises(ValueError, match=REGEXP[re_key]):
|
2647 | 2653 | mpl.axes.Axes._parse_scatter_color_args(
|
@@ -6803,9 +6809,9 @@ def test_color_length_mismatch():
|
6803 | 6809 | fig, ax = plt.subplots()
|
6804 | 6810 | with pytest.raises(ValueError):
|
6805 | 6811 | ax.scatter(x, y, c=colors)
|
6806 |
| - c_rgb = (0.5, 0.5, 0.5) |
6807 |
| - ax.scatter(x, y, c=c_rgb) |
6808 |
| - ax.scatter(x, y, c=[c_rgb] * N) |
| 6812 | + with pytest.warns(match="argument looks like a single numeric RGB"): |
| 6813 | + ax.scatter(x, y, c=(0.5, 0.5, 0.5)) |
| 6814 | + ax.scatter(x, y, c=[(0.5, 0.5, 0.5)] * N) |
6809 | 6815 |
|
6810 | 6816 |
|
6811 | 6817 | def test_eventplot_legend():
|
@@ -7688,7 +7694,8 @@ def test_2dcolor_plot(fig_test, fig_ref):
|
7688 | 7694 | # plot with 1D-color:
|
7689 | 7695 | axs = fig_test.subplots(5)
|
7690 | 7696 | axs[0].plot([1, 2], [1, 2], c=color.reshape(-1))
|
7691 |
| - axs[1].scatter([1, 2], [1, 2], c=color.reshape(-1)) |
| 7697 | + with pytest.warns(match="argument looks like a single numeric RGB"): |
| 7698 | + axs[1].scatter([1, 2], [1, 2], c=color.reshape(-1)) |
7692 | 7699 | axs[2].step([1, 2], [1, 2], c=color.reshape(-1))
|
7693 | 7700 | axs[3].hist(np.arange(10), color=color.reshape(-1))
|
7694 | 7701 | axs[4].bar(np.arange(10), np.arange(10), color=color.reshape(-1))
|
|
0 commit comments