MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_colormap_copy

Function test_colormap_copy

lib/matplotlib/tests/test_colors.py:108–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106
107
108def 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
132def test_colormap_equals():

Callers

nothing calls this directly

Calls 2

set_badMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…