Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e551980

Browse files
authored
Merge pull request #14246 from timhoffm/deprecate-makeMappingArray
Deprecate public use of makeMappingArray
2 parents 94c8e25 + fa32d12 commit e551980

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
The function `matplotlib.colors.makeMappingArray` is not considered part of
5+
the public API any longer. Thus, it's deprecated.

lib/matplotlib/colors.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
import numpy as np
6767
import matplotlib.cbook as cbook
68+
from matplotlib import docstring
6869
from ._color_data import BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS, XKCD_COLORS
6970

7071

@@ -362,7 +363,7 @@ class ColorConverter(object):
362363
### End of backwards-compatible color-conversion API
363364

364365

365-
def makeMappingArray(N, data, gamma=1.0):
366+
def _create_lookup_table(N, data, gamma=1.0):
366367
r"""Create an *N* -element 1-d lookup table.
367368
368369
This assumes a mapping :math:`f : [0, 1] \rightarrow [0, 1]`. The returned
@@ -460,6 +461,13 @@ def makeMappingArray(N, data, gamma=1.0):
460461
return np.clip(lut, 0.0, 1.0)
461462

462463

464+
@cbook.deprecated("3.2",
465+
addendum='This is not considered public API any longer.')
466+
@docstring.copy(_create_lookup_table)
467+
def makeMappingArray(N, data, gamma=1.0):
468+
return _create_lookup_table(N, data, gamma)
469+
470+
463471
class Colormap(object):
464472
"""
465473
Baseclass for all scalar to RGBA mappings.
@@ -729,14 +737,14 @@ def __init__(self, name, segmentdata, N=256, gamma=1.0):
729737

730738
def _init(self):
731739
self._lut = np.ones((self.N + 3, 4), float)
732-
self._lut[:-3, 0] = makeMappingArray(
740+
self._lut[:-3, 0] = _create_lookup_table(
733741
self.N, self._segmentdata['red'], self._gamma)
734-
self._lut[:-3, 1] = makeMappingArray(
742+
self._lut[:-3, 1] = _create_lookup_table(
735743
self.N, self._segmentdata['green'], self._gamma)
736-
self._lut[:-3, 2] = makeMappingArray(
744+
self._lut[:-3, 2] = _create_lookup_table(
737745
self.N, self._segmentdata['blue'], self._gamma)
738746
if 'alpha' in self._segmentdata:
739-
self._lut[:-3, 3] = makeMappingArray(
747+
self._lut[:-3, 3] = _create_lookup_table(
740748
self.N, self._segmentdata['alpha'], 1)
741749
self._isinit = True
742750
self._set_extremes()

lib/matplotlib/tests/test_colors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
(2, [1, 0]),
2222
(1, [0]),
2323
])
24-
def test_makeMappingArray(N, result):
24+
def test_create_lookup_table(N, result):
2525
data = [(0.0, 1.0, 1.0), (0.5, 0.2, 0.2), (1.0, 0.0, 0.0)]
26-
assert_array_almost_equal(mcolors.makeMappingArray(N, data), result)
26+
assert_array_almost_equal(mcolors._create_lookup_table(N, data), result)
2727

2828

2929
def test_resample():

0 commit comments

Comments
 (0)