Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8c582e4

Browse filesBrowse files
committed
colors: avoid problems with bad values under the mask when color mapping
This change should have no effect on any plot, but it avoids warnings that can arise when an inf occurs under a mask.
1 parent 1bf4dde commit 8c582e4
Copy full SHA for 8c582e4

File tree

Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,10 @@ def __call__(self, X, alpha=None, bytes=False):
510510
xa = np.array([X])
511511
else:
512512
vtype = 'array'
513-
xma = ma.array(X, copy=False)
514-
mask_bad = xma.mask
515-
xa = xma.data.copy() # Copy here to avoid side effects.
513+
xma = ma.array(X, copy=True) # Copy here to avoid side effects.
514+
mask_bad = xma.mask # Mask will be used below.
515+
xa = xma.filled() # Fill to avoid infs, etc.
516516
del xma
517-
# masked values are substituted below; no need to fill them here
518517

519518
if xa.dtype.char in np.typecodes['Float']:
520519
# Treat 1.0 as slightly less than 1.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.