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

Skip to content

Commit 3a42131

Browse files
committed
Replace _putmask calls with copyto calls
1 parent 79b9ee0 commit 3a42131

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

lib/matplotlib/colors.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def __call__(self, X, alpha=None, bytes=False):
473473
# Treat 1.0 as slightly less than 1.
474474
vals = np.array([1, 0], dtype=xa.dtype)
475475
almost_one = np.nextafter(*vals)
476-
cbook._putmask(xa, xa == 1.0, almost_one)
476+
np.copyto(xa, almost_one, where=xa == 1.0)
477477
# The following clip is fast, and prevents possible
478478
# conversion of large positive values to negative integers.
479479

@@ -482,15 +482,15 @@ def __call__(self, X, alpha=None, bytes=False):
482482

483483
# ensure that all 'under' values will still have negative
484484
# value after casting to int
485-
cbook._putmask(xa, xa < 0.0, -1)
485+
np.copyto(xa, -1, where=xa < 0.0)
486486
xa = xa.astype(int)
487487
# Set the over-range indices before the under-range;
488488
# otherwise the under-range values get converted to over-range.
489-
cbook._putmask(xa, xa > self.N - 1, self._i_over)
490-
cbook._putmask(xa, xa < 0, self._i_under)
489+
np.copyto(xa, self._i_over, where=xa > self.N - 1)
490+
np.copyto(xa, self._i_under, where=xa < 0)
491491
if mask_bad is not None:
492492
if mask_bad.shape == xa.shape:
493-
cbook._putmask(xa, mask_bad, self._i_bad)
493+
np.copyto(xa, self._i_bad, where=mask_bad)
494494
elif mask_bad:
495495
xa.fill(self._i_bad)
496496
if bytes:
@@ -990,7 +990,7 @@ def __call__(self, value, clip=None):
990990
mask = (resdat <= 0)
991991
else:
992992
mask |= resdat <= 0
993-
cbook._putmask(resdat, mask, 1)
993+
np.copyto(resdat, 1, where=mask)
994994
np.log(resdat, resdat)
995995
resdat -= np.log(vmin)
996996
resdat /= (np.log(vmax) - np.log(vmin))

lib/matplotlib/quiver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ def _h_arrows(self, length):
707707
Y0 = shrink * Y0[np.newaxis, :]
708708
short = np.repeat(length < minsh, 8, axis=1)
709709
# Now select X0, Y0 if short, otherwise X, Y
710-
cbook._putmask(X, short, X0)
711-
cbook._putmask(Y, short, Y0)
710+
np.copyto(X, X0, where=short)
711+
np.copyto(Y, Y0, where=short)
712712
if self.pivot == 'middle':
713713
X -= 0.5 * X[:, 3, np.newaxis]
714714
elif self.pivot == 'tip':
@@ -728,8 +728,8 @@ def _h_arrows(self, length):
728728
X1 = np.repeat(x1[np.newaxis, :], N, axis=0)
729729
Y1 = np.repeat(y1[np.newaxis, :], N, axis=0)
730730
tooshort = np.repeat(tooshort, 8, 1)
731-
cbook._putmask(X, tooshort, X1)
732-
cbook._putmask(Y, tooshort, Y1)
731+
np.copyto(X, X1, where=tooshort)
732+
np.copyto(Y, Y1, where=tooshort)
733733
# Mask handling is deferred to the caller, _make_verts.
734734
return X, Y
735735

0 commit comments

Comments
 (0)