Skip to content

Commit 6985111

Browse files
committed
updates based on feedback from review, @oscargus, @anntzer
1 parent 5e0266a commit 6985111

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

lib/matplotlib/colors.py

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,14 +1595,14 @@ def with_extremes(self, *, bad=None, under=None, over=None):
15951595
15961596
Parameters
15971597
----------
1598-
bad: :mpltype:`color`, default: None
1598+
bad : :mpltype:`color`, default: None
15991599
If Matplotlib color, the bad value is set accordingly in the copy
16001600
1601-
under: tuple of :mpltype:`color`, default: None
1601+
under : tuple of :mpltype:`color`, default: None
16021602
If tuple, the ``under`` value of each component is set with the values
16031603
from the tuple.
16041604
1605-
over: tuple of :mpltype:`color`, default: None
1605+
over : tuple of :mpltype:`color`, default: None
16061606
If tuple, the ``over`` value of each component is set with the values
16071607
from the tuple.
16081608
@@ -3255,12 +3255,13 @@ def __init__(self, norms, vmin=None, vmax=None, clip=False):
32553255

32563256
if isinstance(norms, str) or not np.iterable(norms):
32573257
raise ValueError("A MultiNorm must be assigned multiple norms")
3258-
norms = [n for n in norms]
3258+
3259+
norms = [*norms]
32593260
for i, n in enumerate(norms):
32603261
if n is None:
32613262
norms[i] = Normalize()
32623263
elif isinstance(n, str):
3263-
scale_cls = scale._get_scale_cls_from_str(n)
3264+
scale_cls = _get_scale_cls_from_str(n)
32643265
norms[i] = mpl.colorizer._auto_norm_from_scale(scale_cls)()
32653266

32663267
# Convert the list of norms to a tuple to make it immutable.
@@ -3354,7 +3355,7 @@ def __call__(self, value, clip=None):
33543355
value
33553356
Data to normalize. Must be of length `n_input` or have a data type with
33563357
`n_input` fields.
3357-
clip : List of bools or bool, optional
3358+
clip : list of bools or bool, optional
33583359
See the description of the parameter *clip* in Normalize.
33593360
If ``None``, defaults to ``self.clip`` (which defaults to
33603361
``False``).
@@ -3424,7 +3425,7 @@ def autoscale_None(self, A):
34243425
self._changed()
34253426

34263427
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"""
34283429
return all([(n.vmin is not None and n.vmax is not None) for n in self.norms])
34293430

34303431
@staticmethod
@@ -4092,3 +4093,32 @@ def from_levels_and_colors(levels, colors, extend='neither'):
40924093

40934094
norm = BoundaryNorm(levels, ncolors=n_data_colors)
40944095
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

lib/matplotlib/scale.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -715,35 +715,6 @@ def get_scale_names():
715715
return sorted(_scale_mapping)
716716

717717

718-
def _get_scale_cls_from_str(scale_as_str):
719-
"""
720-
Returns the scale class from a string.
721-
722-
Used in the creation of norms from a string to ensure a reasonable error
723-
in the case where an invalid string is used. This cannot use
724-
`_api.check_getitem()`, because the norm keyword accepts arguments
725-
other than strings.
726-
727-
Parameters
728-
----------
729-
scale_as_str : string
730-
A string corresponding to a scale
731-
732-
Returns
733-
-------
734-
A subclass of ScaleBase.
735-
736-
"""
737-
try:
738-
scale_cls = _scale_mapping[scale_as_str]
739-
except KeyError:
740-
raise ValueError(
741-
"Invalid norm str name; the following values are "
742-
f"supported: {', '.join(_scale_mapping)}"
743-
) from None
744-
return scale_cls
745-
746-
747718
def scale_factory(scale, axis, **kwargs):
748719
"""
749720
Return a scale class by name.

0 commit comments

Comments
 (0)
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