def test_relative_luminance():
 out1 = utils.relative_luminance('white')
 assert_equal(out1, 1)
 out2 = utils.relative_luminance('#000000')
 assert_equal(out2, 0)
 out3 = utils.relative_luminance((0.25, 0.5, 0.75))
 nose.tools.assert_almost_equal(out3, 0.201624536)
 rgbs = mpl.cm.RdBu(np.linspace(0, 1, 10))
 lums1 = [utils.relative_luminance(rgb) for rgb in rgbs]
 lums2 = utils.relative_luminance(rgbs)
 for (lum1, lum2) in zip(lums1, lums2):
  nose.tools.assert_almost_equal(lum1, lum2)

def test_relative_luminance ( ) : out1 = utils . relative_luminance ( 'white' ) assert_equal ( out1 , 1 ) out2 = utils . relative_luminance ( '#000000' ) assert_equal ( out2 , 0 ) out3 = utils . relative_luminance ( ( 0.25 , 0.5 , 0.75 ) ) nose . tools . assert_almost_equal ( out3 , 0.201624536 ) rgbs = mpl . cm . RdBu ( np . linspace ( 0 , 1 , 10 ) ) lums1 = [ utils . relative_luminance ( rgb ) for rgb in rgbs ] lums2 = utils . relative_luminance ( rgbs ) for ( lum1 , lum2 ) in zip ( lums1 , lums2 ) : nose . tools . assert_almost_equal ( lum1 , lum2 )
test relative luminance .