Skip to content

Numpy 1.17.0 breaks test_colors #14900

@bingyao

Description

@bingyao

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy