matplotlib/matplotlib — pull request #3031 by jrjohansson (2014-05-02 06:41:06+00:00)
Title: avoid np.nan values in colors array returned by axes3d._shade_colors

Fix bug in Axes3D._shade_colors

There is a problem with handling NaN values in the shade array in on line 1677 in axes3d.py. If proj3d.mod(n) the corresponding value in shade is nan, and the it masked out from the shade array shade using the mask `mask` on lines 1681 - 1682 but not line 1688. As a result the colors array will include nan values, and the following warnings are displaced when for example calling the `bar3d` function

.../lib/python3.4/site-packages/matplotlib-1.4.x-py3.4-linux-x86_64.egg/mpl_toolkits/mplot3d/axes3d.py:1679: RuntimeWarning: invalid value encountered in true_divide
for n in normals])
.../lib/python3.4/site-packages/matplotlib-1.4.x-py3.4-linux-x86_64.egg/matplotlib/colors.py:401: RuntimeWarning: invalid value encountered in greater
if (c.ravel() > 1).any() or (c.ravel() < 0).any():
.../python3.4/site-packages/matplotlib-1.4.x-py3.4-linux-x86_64.egg/matplotlib/colors.py:401: RuntimeWarning: invalid value encountered in less
if (c.ravel() > 1).any() or (c.ravel() < 0).any():

(because here the array c includes nan values and the comparison operations fail).

This PR fixes this by avoiding nan in the shades array in Axes3D._shade_colors.