Check the generated _lut data of a colormap and corresponding reversed colormap if they are almost the same.
(name)
| 1206 | |
| 1207 | @pytest.mark.parametrize('name', sorted(mpl.colormaps())) |
| 1208 | def 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 | |
| 1225 | def test_has_alpha_channel(): |