@@ -205,6 +205,34 @@ def gray_from_float_rgba():
205205 assert_raises (ValueError , gray_from_float_rgba )
206206
207207
208+ def test_light_source_shading_color_range ():
209+ # see also
210+ #http://matplotlib.org/examples/pylab_examples/shading_example.html
211+
212+ from matplotlib .colors import LightSource
213+ from matplotlib .colors import Normalize
214+
215+ refinput = np .array ([[1 , 2 , 3 , 4 ], [5 , 6 , 7 , 8 ], [9 , 10 , 11 , 12 ]])
216+ norm = Normalize (vmin = 0 , vmax = 50 )
217+ ls = LightSource (azdeg = 0 , altdeg = 65 )
218+ testoutput = ls .shade (refinput , plt .cm .jet , norm = norm )
219+ refoutput = np .array ([
220+ [[0. , 0. , 0.58912656 , 1. ],
221+ [0. , 0. , 0.67825312 , 1. ],
222+ [0. , 0. , 0.76737968 , 1. ],
223+ [0. , 0. , 0.85650624 , 1. ]],
224+ [[0. , 0. , 0.9456328 , 1. ],
225+ [0. , 0. , 1. , 1. ],
226+ [0. , 0.04901961 , 1. , 1. ],
227+ [0. , 0.12745098 , 1. , 1. ]],
228+ [[0. , 0.22156863 , 1. , 1. ],
229+ [0. , 0.3 , 1. , 1. ],
230+ [0. , 0.37843137 , 1. , 1. ],
231+ [0. , 0.45686275 , 1. , 1. ]]
232+ ])
233+ assert_array_almost_equal (refoutput , testoutput )
234+
235+
208236if __name__ == '__main__' :
209237 import nose
210238 nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments