@@ -1595,14 +1595,14 @@ def with_extremes(self, *, bad=None, under=None, over=None):
1595
1595
1596
1596
Parameters
1597
1597
----------
1598
- bad: :mpltype:`color`, default: None
1598
+ bad : :mpltype:`color`, default: None
1599
1599
If Matplotlib color, the bad value is set accordingly in the copy
1600
1600
1601
- under: tuple of :mpltype:`color`, default: None
1601
+ under : tuple of :mpltype:`color`, default: None
1602
1602
If tuple, the ``under`` value of each component is set with the values
1603
1603
from the tuple.
1604
1604
1605
- over: tuple of :mpltype:`color`, default: None
1605
+ over : tuple of :mpltype:`color`, default: None
1606
1606
If tuple, the ``over`` value of each component is set with the values
1607
1607
from the tuple.
1608
1608
@@ -3255,12 +3255,13 @@ def __init__(self, norms, vmin=None, vmax=None, clip=False):
3255
3255
3256
3256
if isinstance (norms , str ) or not np .iterable (norms ):
3257
3257
raise ValueError ("A MultiNorm must be assigned multiple norms" )
3258
- norms = [n for n in norms ]
3258
+
3259
+ norms = [* norms ]
3259
3260
for i , n in enumerate (norms ):
3260
3261
if n is None :
3261
3262
norms [i ] = Normalize ()
3262
3263
elif isinstance (n , str ):
3263
- scale_cls = scale . _get_scale_cls_from_str (n )
3264
+ scale_cls = _get_scale_cls_from_str (n )
3264
3265
norms [i ] = mpl .colorizer ._auto_norm_from_scale (scale_cls )()
3265
3266
3266
3267
# Convert the list of norms to a tuple to make it immutable.
@@ -3354,7 +3355,7 @@ def __call__(self, value, clip=None):
3354
3355
value
3355
3356
Data to normalize. Must be of length `n_input` or have a data type with
3356
3357
`n_input` fields.
3357
- clip : List of bools or bool, optional
3358
+ clip : list of bools or bool, optional
3358
3359
See the description of the parameter *clip* in Normalize.
3359
3360
If ``None``, defaults to ``self.clip`` (which defaults to
3360
3361
``False``).
@@ -3424,7 +3425,7 @@ def autoscale_None(self, A):
3424
3425
self ._changed ()
3425
3426
3426
3427
def scaled (self ):
3427
- """Return whether both *vmin* and *vmax* are set on all constitient norms"""
3428
+ """Return whether both *vmin* and *vmax* are set on all constituent norms"""
3428
3429
return all ([(n .vmin is not None and n .vmax is not None ) for n in self .norms ])
3429
3430
3430
3431
@staticmethod
@@ -4092,3 +4093,32 @@ def from_levels_and_colors(levels, colors, extend='neither'):
4092
4093
4093
4094
norm = BoundaryNorm (levels , ncolors = n_data_colors )
4094
4095
return cmap , norm
4096
+
4097
+
4098
+ def _get_scale_cls_from_str (scale_as_str ):
4099
+ """
4100
+ Returns the scale class from a string.
4101
+
4102
+ Used in the creation of norms from a string to ensure a reasonable error
4103
+ in the case where an invalid string is used. This cannot use
4104
+ `_api.check_getitem()`, because the norm keyword accepts arguments
4105
+ other than strings.
4106
+
4107
+ Parameters
4108
+ ----------
4109
+ scale_as_str : string
4110
+ A string corresponding to a scale
4111
+
4112
+ Returns
4113
+ -------
4114
+ A subclass of ScaleBase.
4115
+
4116
+ """
4117
+ try :
4118
+ scale_cls = scale ._scale_mapping [scale_as_str ]
4119
+ except KeyError :
4120
+ raise ValueError (
4121
+ "Invalid norm str name; the following values are "
4122
+ f"supported: { ', ' .join (scale ._scale_mapping )} "
4123
+ ) from None
4124
+ return scale_cls
0 commit comments