def test_resample():
 n = 101
 colorlist = np.empty((n, 4), float)
 colorlist[:, 0] = np.linspace(0, 1, n)
 colorlist[:, 1] = 0.2
 colorlist[:, 2] = np.linspace(1, 0, n)
 colorlist[:, 3] = 0.7
 lsc = mcolors.LinearSegmentedColormap.from_list(u'lsc', colorlist)
 lc = mcolors.ListedColormap(colorlist)
 lsc3 = lsc._resample(3)
 lc3 = lc._resample(3)
 expected = np.array([[0.0, 0.2, 1.0, 0.7], [0.5, 0.2, 0.5, 0.7], [1.0, 0.2, 0.0, 0.7]], float)
 assert_array_almost_equal(lsc3([0, 0.5, 1]), expected)
 assert_array_almost_equal(lc3([0, 0.5, 1]), expected)

def test_resample ( ) : n = 101 colorlist = np . empty ( ( n , 4 ) , float ) colorlist [ : , 0 ] = np . linspace ( 0 , 1 , n ) colorlist [ : , 1 ] = 0.2 colorlist [ : , 2 ] = np . linspace ( 1 , 0 , n ) colorlist [ : , 3 ] = 0.7 lsc = mcolors . LinearSegmentedColormap . from_list ( u'lsc' , colorlist ) lc = mcolors . ListedColormap ( colorlist ) lsc3 = lsc . _resample ( 3 ) lc3 = lc . _resample ( 3 ) expected = np . array ( [ [ 0.0 , 0.2 , 1.0 , 0.7 ] , [ 0.5 , 0.2 , 0.5 , 0.7 ] , [ 1.0 , 0.2 , 0.0 , 0.7 ] ] , float ) assert_array_almost_equal ( lsc3 ( [ 0 , 0.5 , 1 ] ) , expected ) assert_array_almost_equal ( lc3 ( [ 0 , 0.5 , 1 ] ) , expected )
github issue #6025 pointed to incorrect listedcolormap .