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
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
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