Skip to content

Commit 1139e6a

Browse files
aitikguptatimhoffm
andauthored
Simplify logic
Co-authored-by: Tim Hoffmann <[email protected]>
1 parent c4b9f9f commit 1139e6a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/cm.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,12 @@ def set_array(self, A):
367367
----------
368368
A : array-like or None
369369
"""
370-
A = cbook.safe_masked_invalid(A, copy=True) if A is not None else None
371-
372-
if (A is not None and A.dtype != np.uint8 and
373-
not np.can_cast(A.dtype, float, "same_kind")):
370+
if A is None:
371+
self._A = None
372+
return
373+
374+
A = cbook.safe_masked_invalid(A, copy=True)
375+
if not np.can_cast(A.dtype, float, "same_kind"):
374376
raise TypeError("Image data of dtype {} cannot be converted to "
375377
"float".format(A.dtype))
376378

0 commit comments

Comments
 (0)