8000 Ignore non-finite vertices when running count_contains by dstansby · Pull Request #8651 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Ignore non-finite vertices when running count_contains #8651

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
May 28, 2017
Merged
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
Ignore non-finite vetices when running count_contains
  • Loading branch information
dstansby committed May 25, 2017
commit bd1d994cfdc4549cab9bd511dcf827fdc49ca6a1
6 changes: 4 additions & 2 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,16 @@ def splity(self, *args):
def count_contains(self, vertices):
"""
Count the number of vertices contained in the :class:`Bbox`.
Any vertices with a non-finite x or y value are ignored.

*vertices* is a Nx2 Numpy array.
"""
if len(vertices) == 0:
return 0
vertices = np.asarray(vertices)
return (
((self.min < vertices) & (vertices < self.max)).all(axis=1).sum())
with np.errstate(invalid='ignore'):
return (((self.min < vertices) &
(vertices < self.max)).all(axis=1).sum())

def count_overlaps(self, bboxes):
"""
Expand Down
0