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

Replace np.compress by boolean indexing. #13384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions 22 lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5814,23 +5814,21 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
# don't plot if C or any of the surrounding vertices are masked.
mask = ma.getmaskarray(C) + xymask

compress = np.compress

ravelmask = (mask == 0).ravel()
X1 = compress(ravelmask, ma.filled(X[:-1, :-1]).ravel())
Y1 = compress(ravelmask, ma.filled(Y[:-1, :-1]).ravel())
X2 = compress(ravelmask, ma.filled(X[1:, :-1]).ravel())
Y2 = compress(ravelmask, ma.filled(Y[1:, :-1]).ravel())
X3 = compress(ravelmask, ma.filled(X[1:, 1:]).ravel())
Y3 = compress(ravelmask, ma.filled(Y[1:, 1:]).ravel())
X4 = compress(ravelmask, ma.filled(X[:-1, 1:]).ravel())
Y4 = compress(ravelmask, ma.filled(Y[:-1, 1:]).ravel())
unmask = ~mask
X1 = ma.filled(X[:-1, :-1])[unmask]
Y1 = ma.filled(Y[:-1, :-1])[unmask]
X2 = ma.filled(X[1:, :-1])[unmask]
Y2 = ma.filled(Y[1:, :-1])[unmask]
X3 = ma.filled(X[1:, 1:])[unmask]
Y3 = ma.filled(Y[1:, 1:])[unmask]
X4 = ma.filled(X[:-1, 1:])[unmask]
Y4 = ma.filled(Y[:-1, 1:])[unmask]
npoly = len(X1)

xy = np.stack([X1, Y1, X2, Y2, X3, Y3, X4, Y4, X1, Y1], axis=-1)
verts = xy.reshape((npoly, 5, 2))

C = compress(ravelmask, ma.filled(C[0:Ny - 1, 0:Nx - 1]).ravel())
C = ma.filled(C[:Ny - 1, :Nx - 1])[unmask]

linewidths = (0.25,)
if 'linewidth' in kwargs:
Expand Down
8 changes: 4 additions & 4 deletions 8 lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,23 +1311,23 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
hival = np.percentile(x, whis[1])

# get high extreme
wiskhi = np.compress(x <= hival, x)
wiskhi = x[x <= hival]
if len(wiskhi) == 0 or np.max(wiskhi) < q3:
stats['whishi'] = q3
else:
stats['whishi'] = np.max(wiskhi)

# get low extreme
wisklo = np.compress(x >= loval, x)
wisklo = x[x >= loval]
if len(wisklo) == 0 or np.min(wisklo) > q1:
stats['whislo'] = q1
else:
stats['whislo'] = np.min(wisklo)

# compute a single array of outliers
stats['fliers'] = np.hstack([
np.compress(x < stats['whislo'], x),
np.compress(x > stats['whishi'], x)
x[x < stats['whislo']],
x[x > stats['whishi']],
])

# add in the remaining stats
Expand Down
4 changes: 2 additions & 2 deletions 4 lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2641,9 +2641,9 @@ def __call__(self):
mod = np.abs((locs - t0) % majorstep)
cond1 = mod > minorstep / 10.0
cond2 = ~np.isclose(mod, majorstep, atol=0)
locs = locs.compress(cond1 & cond2)
locs = locs[cond1 & cond2]

return self.raise_if_exceeds(np.array(locs))
return self.raise_if_exceeds(locs)

def tick_values(self, vmin, vmax):
raise NotImplementedError('Cannot get tick locations for a '
Expand Down
2 changes: 1 addition & 1 deletion 2 lib/matplotlib/tri/triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_masked_triangles(self):
Return an array of triangles that are not masked.
"""
if self.mask is not None:
return self.triangles.compress(1 - self.mask, axis=0)
return self.triangles[~self.mask]
else:
return self.triangles

Expand Down
2 changes: 1 addition & 1 deletion 2 lib/matplotlib/tri/tripcolor.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None,
C = C[maskedTris].mean(axis=1)
elif tri.mask is not None:
# Remove color values of masked triangles.
C = C.compress(1-tri.mask)
C = C[~tri.mask]

collection = PolyCollection(verts, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion 2 lib/matplotlib/tri/tritools.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _total_to_compress_renum(mask, n=None):
n = np.size(mask)
if mask is not None:
renum = np.full(n, -1, dtype=np.int32) # Default num is -1
valid = np.arange(n, dtype=np.int32).compress(~mask, axis=0)
valid = np.arange(n, dtype=np.int32)[~mask]
renum[valid] = np.arange(np.size(valid, 0), dtype=np.int32)
return renum
else:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.