Skip to content

Numpy 1.17.0 breaks test_colors #14900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bingyao opened this issue Jul 27, 2019 · 0 comments · Fixed by #14901
Closed

Numpy 1.17.0 breaks test_colors #14900

bingyao opened this issue Jul 27, 2019 · 0 comments · Fixed by #14901
Milestone

Comments

@bingyao
Copy link
Contributor

bingyao commented Jul 27, 2019

It seems that Numpy 1.17.0 produces a IndexError: invalid index to scalar variable. in test_colors.py (testing failure trace log):

FAILED lib/matplotlib/tests/test_colors.py::test_light_source_masked_shading

def test_light_source_masked_shading():
        """Array comparison test for a surface with a masked portion. Ensures that
        we don't wind up with "fringes" of odd colors around masked regions."""
        y, x = np.mgrid[-1.2:1.2:8j, -1.2:1.2:8j]
        z = 10 * np.cos(x**2 + y**2)
    
        z = np.ma.masked_greater(z, 9.9)
    
        cmap = plt.cm.copper
        ls = mcolors.LightSource(315, 45)
>       rgb = ls.shade(z, cmap)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-6-96ee2a102cfd> in <module>
      1 cmap = plt.cm.copper
      2 ls = mcolors.LightSource(315, 45)
----> 3 rgb = ls.shade(z, cmap)

~/visualization/matplotlib/lib/matplotlib/colors.py in shade(self, data, cmap, norm, blend_mode, vmin, vmax, vert_exag, dx, dy, fraction, **kwargs)
   1800         rgb1 = self.shade_rgb(rgb0, elevation=data, blend_mode=blend_mode,
   1801                               vert_exag=vert_exag, dx=dx, dy=dy,
-> 1802                               fraction=fraction, **kwargs)
   1803         # Don't overwrite the alpha channel, if present.
   1804         rgb0[..., :3] = rgb1[..., :3]

~/visualization/matplotlib/lib/matplotlib/colors.py in shade_rgb(self, rgb, elevation, fraction, blend_mode, vert_exag, dx, dy, **kwargs)
   1871         # Only apply result where hillshade intensity isn't masked
   1872         if hasattr(intensity, 'mask'):
-> 1873             mask = intensity.mask[..., 0]
   1874             for i in range(3):
   1875                 blend[..., i][mask] = rgb[..., i][mask]

IndexError: invalid index to scalar variable.
tacaswell added a commit that referenced this issue Jul 28, 2019
Fix:  numpy 1.17.0 breaks test_colors.

closes #14900
@QuLogic QuLogic added this to the v2.2.5 milestone Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants