Blob Blame History Raw
From 3bdd39049ac391cbd8a0a629797ca0630384b8d7 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Thu, 21 Sep 2023 12:05:06 -0400
Subject: [PATCH] Replace deprecated/removed matplotlib.cm.LUTSIZE

Ref: https://github.com/matplotlib/matplotlib/pull/20806/
---
 nipy/labs/viz_tools/cm.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/nipy/labs/viz_tools/cm.py b/nipy/labs/viz_tools/cm.py
index 69528ac72..3848f7d8f 100644
--- a/nipy/labs/viz_tools/cm.py
+++ b/nipy/labs/viz_tools/cm.py
@@ -11,6 +11,7 @@
 try:
     from matplotlib import cm as _cm
     from matplotlib import colors as _colors
+    from matplotlib import rcParams as _rc
 except ImportError:
     skip_if_running_nose('Could not import matplotlib')
 
@@ -109,7 +110,7 @@ def alpha_cmap(color, name=''):
                 (red, green, blue, 1.),
                ]
     cmap = _colors.LinearSegmentedColormap.from_list(
-                                '%s_transparent' % name, cmapspec, _cm.LUTSIZE)
+                                '%s_transparent' % name, cmapspec, _rc['image.lut'])
     cmap._init()
     cmap._lut[:, -1] = _np.linspace(.5, 1.0, cmap._lut.shape[0])
     cmap._lut[-1, -1] = 0
@@ -159,7 +160,7 @@ def alpha_cmap(color, name=''):
     _cmapspec = _cmaps_data[_cmapname]
     if 'red' in _cmapspec:
         _cmap_d[_cmapname] = _colors.LinearSegmentedColormap(
-            _cmapname, _cmapspec, _cm.LUTSIZE)
+            _cmapname, _cmapspec, _rc['image.lut'])
         _cmap_d[_cmapname_r] = _cmap_d[_cmapname].reversed(name=_cmapname_r)
     else:
         _revspec = list(reversed(_cmapspec))
@@ -167,9 +168,9 @@ def alpha_cmap(color, name=''):
             _revspec = [(1.0 - a, b) for a, b in _revspec]
 
         _cmap_d[_cmapname] = _colors.LinearSegmentedColormap.from_list(
-                                _cmapname, _cmapspec, _cm.LUTSIZE)
+                                _cmapname, _cmapspec, _rc['image.lut'])
         _cmap_d[_cmapname_r] = _colors.LinearSegmentedColormap.from_list(
-                                _cmapname_r, _revspec, _cm.LUTSIZE)
+                                _cmapname_r, _revspec, _rc['image.lut'])
 
 ################################################################################
 # A few transparent colormaps
@@ -207,7 +208,7 @@ def dim_cmap(cmap, factor=.3, to_white=True):
     return _colors.LinearSegmentedColormap(
                                 '%s_dimmed' % cmap.name,
                                 cdict,
-                                _cm.LUTSIZE)
+                                _rc['image.lut'])
 
 
 def replace_inside(outer_cmap, inner_cmap, vmin, vmax):
@@ -267,6 +268,6 @@ def replace_inside(outer_cmap, inner_cmap, vmin, vmax):
     return _colors.LinearSegmentedColormap(
                                 '%s_inside_%s' % (inner_cmap.name, outer_cmap.name),
                                 cdict,
-                                _cm.LUTSIZE)
+                                _rc['image.lut'])