From eeac3df238994109d7871d9f267717f8419e040a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Tue, 26 Nov 2024 15:19:35 +0100 Subject: [PATCH] Avoid a deprecation warning from matplotlib 3.11 (dev) --- cmocean/cm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmocean/cm.py b/cmocean/cm.py index 7ffe563..7705f17 100644 --- a/cmocean/cm.py +++ b/cmocean/cm.py @@ -53,11 +53,12 @@ def _register_cmap(cmap, *, name): rgb_with_alpha = np.zeros((rgb.shape[0],4)) rgb_with_alpha[:,:3] = rgb rgb_with_alpha[:,3] = 1. #set alpha channel to 1 - reg_map = colors.ListedColormap(rgb_with_alpha, N=rgb.shape[0]) + assert len(rgb_with_alpha) == rgb.shape[0] + reg_map = colors.ListedColormap(rgb_with_alpha) _register_cmap(reg_map, name=f'cmo.{cmapname}') # Register the reversed map - reg_map_r = colors.ListedColormap(rgb_with_alpha[::-1,:], N=rgb.shape[0]) + reg_map_r = colors.ListedColormap(rgb_with_alpha[::-1,:]) _register_cmap(reg_map_r, name=f'cmo.{cmapname}_r') # Load inverted cmaps @@ -71,9 +72,10 @@ def _register_cmap(cmap, *, name): rgb_with_alpha[:,3] = 1. #set alpha channel to 1 # Register inverted cmaps - reg_map_i = colors.ListedColormap(rgb_with_alpha, N=rgb_i.shape[0]) + assert len(rgb_with_alpha) == rgb_i.shape[0] + reg_map_i = colors.ListedColormap(rgb_with_alpha) _register_cmap(reg_map_i, name=f'cmo.{cmapname}_i') - reg_map_r_i = colors.ListedColormap(rgb_with_alpha[::-1,:], N=rgb_i.shape[0]) + reg_map_r_i = colors.ListedColormap(rgb_with_alpha[::-1,:]) _register_cmap(reg_map_r_i, name=f'cmo.{cmapname}_r_i') # order shouldn't matter