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

Skip to content

Commit b8d43a9

Browse files
committed
Treat one as slightly less than one
1 parent 21ea65f commit b8d43a9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/colors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ def __call__(self, X, alpha=None, bytes=False):
474474
else:
475475
vtype = 'array'
476476
if isinstance(self, BivariateColormap):
477+
vals = np.array([1, 0], dtype=X.dtype)
478+
almost_one = np.nextafter(*vals)
479+
np.copyto(X, almost_one, where=X == 1.0)
477480
X[0] = X[0] * 256
478481
X[1] = X[1] * 256
479482
X = X.astype(int)
@@ -482,7 +485,6 @@ def __call__(self, X, alpha=None, bytes=False):
482485
mask_bad = xma.mask # Mask will be used below.
483486
xa = xma.filled() # Fill to avoid infs, etc.
484487
del xma
485-
486488
# Calculations with native byteorder are faster, and avoid a
487489
# bug that otherwise can occur with putmask when the last
488490
# argument is a numpy scalar.

0 commit comments

Comments
 (0)