Skip to content

Commit ca00835

Browse files
committed
optimize imshow
1 parent c0d9c98 commit ca00835

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

lib/matplotlib/cbook.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,7 @@ def safe_masked_invalid(x, copy=False):
731731
# copy with the byte order swapped.
732732
x = x.byteswap(inplace=copy).newbyteorder('N') # Swap to native order.
733733
try:
734-
xm = np.ma.masked_invalid(x, copy=False)
735-
xm.shrink_mask()
734+
xm = np.ma.masked_where(~(np.isfinite(x)), x, copy=False)
736735
except TypeError:
737736
return x
738737
return xm

lib/matplotlib/cm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,5 +735,5 @@ def _ensure_cmap(cmap):
735735
cmap_name = cmap if cmap is not None else mpl.rcParams["image.cmap"]
736736
# use check_in_list to ensure type stability of the exception raised by
737737
# the internal usage of this (ValueError vs KeyError)
738-
_api.check_in_list(sorted(_colormaps), cmap=cmap_name)
738+
_api.check_in_list(list(_colormaps), cmap=cmap_name)
739739
return mpl.colormaps[cmap_name]

lib/matplotlib/colors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,10 @@ def autoscale(self, A):
13901390
def autoscale_None(self, A):
13911391
"""If vmin or vmax are not set, use the min/max of *A* to set them."""
13921392
A = np.asanyarray(A)
1393+
1394+
if isinstance(A, np.ma.MaskedArray) and A.mask is False:
1395+
A = A.data
1396+
13931397
if self.vmin is None and A.size:
13941398
self.vmin = A.min()
13951399
if self.vmax is None and A.size:

0 commit comments

Comments
 (0)