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

Skip to content

Commit a752b67

Browse files
trygvradQuLogic
andauthored
Apply suggestions from code review
Co-authored-by: Elliott Sales de Andrade <[email protected]>
1 parent f7681c6 commit a752b67

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

lib/matplotlib/cbook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def safe_masked_invalid(x, copy=False):
701701
try:
702702
mask = np.empty(x.shape, dtype=np.dtype('bool, '*len(x.dtype.descr)))
703703
for dd, dm in zip(x.dtype.descr, mask.dtype.descr):
704-
mask[dm[0]] = ~(np.isfinite(x[dd[0]]))
704+
mask[dm[0]] = ~np.isfinite(x[dd[0]])
705705
xm = np.ma.array(x, mask=mask, copy=False)
706706
except TypeError:
707707
return x

lib/matplotlib/colorizer.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ def _set_cmap(self, cmap):
222222
# bury import to avoid circular imports
223223
in_init = self._cmap is None
224224
cmap_obj = _ensure_cmap(cmap, accept_multivariate=True)
225-
if not in_init:
226-
if self.norm.n_components != cmap_obj.n_variates:
225+
if not in_init and self.norm.n_components != cmap_obj.n_variates:
227226
raise ValueError(f"The colormap {cmap} does not support "
228227
f"{self.norm.n_components} variates as required by "
229228
f"the {type(self.norm)} on this Colorizer")
@@ -784,9 +783,7 @@ def _ensure_norm(norm, n_components=1):
784783
if isinstance(norm, colors.MultiNorm) and norm.n_components == n_components:
785784
return norm
786785
raise ValueError(
787-
"Invalid norm for multivariate colormap with "
788-
f"{n_components} inputs"
789-
)
786+
f"Invalid norm for multivariate colormap with {n_components} inputs")
790787

791788

792789
def _ensure_cmap(cmap, accept_multivariate=False):
@@ -870,12 +867,12 @@ def _ensure_multivariate_data(data, n_components):
870867
Parameters
871868
----------
872869
n_components : int
873-
- number of variates in the data
870+
Number of variates in the data.
874871
data : np.ndarray, PIL.Image or None
875872
876873
Returns
877874
-------
878-
np.ndarray, PIL.Image or None
875+
np.ndarray, PIL.Image or None
879876
"""
880877

881878
if isinstance(data, np.ndarray):

lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ def test_colorizer_multinorm_explicit():
21842184

21852185
with pytest.raises(ValueError,
21862186
match=("Invalid norm for multivariate colormap with 2 inputs")):
2187-
ca = mcolorizer.Colorizer('BiOrangeBlue', ['linear', 'linear', "log"])
2187+
ca = mcolorizer.Colorizer('BiOrangeBlue', ['linear', 'linear', 'log'])
21882188

21892189
# valid explicit construction
21902190
ca = mcolorizer.Colorizer('BiOrangeBlue', [mcolors.Normalize(), 'log'])

lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def test_format_cursor_data_multinorm(data, text):
467467

468468
# This is a test for ColorizingArtist._format_cursor_data_override()
469469
# with data with multiple channels.
470-
# It includes is a workaround so that we can test this functionality
470+
# It includes a workaround so that we can test this functionality
471471
# before the MultiVar/BiVariate colormaps and MultiNorm are exposed
472472
# via the top-level methods (ax.imshow())
473473
# i.e. we here set the hidden variables _cmap and _norm

0 commit comments

Comments
 (0)