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

Function test_colormap_reversing

lib/matplotlib/tests/test_colors.py:1208–1222  ·  view source on GitHub ↗

Check the generated _lut data of a colormap and corresponding reversed colormap if they are almost the same.

(name)

Source from the content-addressed store, hash-verified

1206
1207@pytest.mark.parametrize('name', sorted(mpl.colormaps()))
1208def test_colormap_reversing(name):
1209 """
1210 Check the generated _lut data of a colormap and corresponding reversed
1211 colormap if they are almost the same.
1212 """
1213 cmap = mpl.colormaps[name]
1214 cmap_r = cmap.reversed()
1215 if not cmap_r._isinit:
1216 cmap._init()
1217 cmap_r._init()
1218 assert_array_almost_equal(cmap._lut[:-3], cmap_r._lut[-4::-1])
1219 # Test the bad, over, under values too
1220 assert_array_almost_equal(cmap(-np.inf), cmap_r(np.inf))
1221 assert_array_almost_equal(cmap(np.inf), cmap_r(-np.inf))
1222 assert_array_almost_equal(cmap(np.nan), cmap_r(np.nan))
1223
1224
1225def test_has_alpha_channel():

Callers

nothing calls this directly

Calls 2

reversedMethod · 0.45
_initMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…