def test_cmap2rgba_interpolation(self): """Check colormap to RGBA interpolation.""" max_planck_duplicates = np.array([ [0., 0.4627451, 0.40784314, 1.], [0.48235294, 0.70980392, 0.67843137, 1.], [0.74901961, 0.85098039, 0.83137255, 1.], [0.96078431, 0.97254902, 0.97647059, 1.], [0.96078431, 0.97254902, 0.97647059, 1.], ]) max_planck_interpolated = np.array([ [0., 0.4627451, 0.40784314, 1.], [0.36318339, 0.64876586, 0.61158016, 1.], [0.6172549, 0.7812226, 0.75580161, 1.], [0.8038293, 0.88244521, 0.86892734, 1.], [0.96078431, 0.97254902, 0.97647059, 1.], ]) assert np.allclose( max_planck_interpolated, colors.cmap2rgba('max_planck', 5, interpolate=True) ) assert np.allclose( max_planck_duplicates, colors.cmap2rgba('max_planck', 5, interpolate=False) )
def test_cmap2rgba(self): """Check colormap to RGB conversion.""" ref = np.loadtxt(os.path.join(self.ref_dir, 'viridis.txt'), comments='%') rgb = colors.cmap2rgba('viridis', 256)[:, :3] # ignore alpha assert np.allclose(ref, rgb, atol=0.001)