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

Skip to content

Commit d4215a3

Browse files
trygvradstory645
andauthored
Apply suggestions from code review
Co-authored-by: hannah <[email protected]>
1 parent 473c89c commit d4215a3

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

lib/matplotlib/colorizer.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def set_clim(self, vmin=None, vmax=None):
249249
The limits.
250250
251251
For scalar data, the limits may also be passed as a
252-
tuple (*vmin*, *vmax*) as a single positional argument.
252+
tuple (*vmin*, *vmax*) single positional argument.
253253
254254
.. ACCEPTS: (vmin: float, vmax: float)
255255
"""
@@ -575,11 +575,7 @@ def set_array(self, A):
575575

576576
A = cbook.safe_masked_invalid(A, copy=True)
577577
if not np.can_cast(A.dtype, float, "same_kind"):
578-
if A.dtype.fields is None:
579-
raise TypeError(f"Image data of dtype {A.dtype} cannot be "
580-
f"converted to float")
581-
else:
582-
for key in A.dtype.fields:
578+
for key in np.atleast_1d(A.dtype.fields):
583579
if not np.can_cast(A[key].dtype, float, "same_kind"):
584580
raise TypeError(f"Image data of dtype {A.dtype} cannot be "
585581
f"converted to a sequence of floats")
@@ -635,7 +631,7 @@ def _get_colorizer(cmap, norm, colorizer):
635631
cmap : str, `~matplotlib.colors.Colormap`, `~matplotlib.colors.BivarColormap`\
636632
or `~matplotlib.colors.MultivarColormap`, default: :rc:`image.cmap`
637633
The Colormap instance or registered colormap name used to map
638-
scalar/multivariate data to colors.
634+
data values to colors.
639635
640636
Multivariate data is only accepted if a multivariate colormap
641637
(`~matplotlib.colors.BivarColormap` or `~matplotlib.colors.MultivarColormap`)
@@ -660,13 +656,13 @@ def _get_colorizer(cmap, norm, colorizer):
660656
before mapping to colors using *cmap*. By default, a linear scaling is
661657
used, mapping the lowest value to 0 and the highest to 1.
662658
663-
If given, this can be one of the following:
659+
This can be one of the following:
664660
665661
- An instance of `.Normalize` or one of its subclasses
666662
(see :ref:`colormapnorms`).
667663
- A scale name, i.e. one of "linear", "log", "symlog", "logit", etc. For a
668664
list of available scales, call `matplotlib.scale.get_scale_names()`.
669-
In that case, a suitable `.Normalize` subclass is dynamically generated
665+
In this case, a suitable `.Normalize` subclass is dynamically generated
670666
and instantiated.
671667
- A list of scale names or `.Normalize` objects matching the number of
672668
variates in the colormap, for use with `~matplotlib.colors.BivarColormap`
@@ -686,7 +682,7 @@ def _get_colorizer(cmap, norm, colorizer):
686682
*vmin*/*vmax* when a *norm* instance is given (but using a `str` *norm*
687683
name together with *vmin*/*vmax* is acceptable).
688684
689-
A list can be used to define independent limits for each variate when
685+
A list of (vmin, vmax) typles can be used to define independent limits for each variate when
690686
using a `~matplotlib.colors.BivarColormap` or
691687
`~matplotlib.colors.MultivarColormap`.""",
692688
)

0 commit comments

Comments
 (0)