| 106 | |
| 107 | |
| 108 | def test_colormap_copy(): |
| 109 | cmap = plt.colormaps["Reds"] |
| 110 | copied_cmap = copy.copy(cmap) |
| 111 | with np.errstate(invalid='ignore'): |
| 112 | ret1 = copied_cmap([-1, 0, .5, 1, np.nan, np.inf]) |
| 113 | cmap2 = copy.copy(copied_cmap) |
| 114 | with pytest.warns(PendingDeprecationWarning): |
| 115 | cmap2.set_bad('g') |
| 116 | with np.errstate(invalid='ignore'): |
| 117 | ret2 = copied_cmap([-1, 0, .5, 1, np.nan, np.inf]) |
| 118 | assert_array_equal(ret1, ret2) |
| 119 | # again with the .copy method: |
| 120 | cmap = plt.colormaps["Reds"] |
| 121 | copied_cmap = cmap.copy() |
| 122 | with np.errstate(invalid='ignore'): |
| 123 | ret1 = copied_cmap([-1, 0, .5, 1, np.nan, np.inf]) |
| 124 | cmap2 = copy.copy(copied_cmap) |
| 125 | with pytest.warns(PendingDeprecationWarning): |
| 126 | cmap2.set_bad('g') |
| 127 | with np.errstate(invalid='ignore'): |
| 128 | ret2 = copied_cmap([-1, 0, .5, 1, np.nan, np.inf]) |
| 129 | assert_array_equal(ret1, ret2) |
| 130 | |
| 131 | |
| 132 | def test_colormap_equals(): |