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

Skip to content

Commit bd1d994

Browse files
committed
Ignore non-finite vetices when running count_contains
1 parent fc6a7ba commit bd1d994

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/transforms.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,14 +645,16 @@ def splity(self, *args):
645645
def count_contains(self, vertices):
646646
"""
647647
Count the number of vertices contained in the :class:`Bbox`.
648+
Any vertices with a non-finite x or y value are ignored.
648649
649650
*vertices* is a Nx2 Numpy array.
650651
"""
651652
if len(vertices) == 0:
652653
return 0
653654
vertices = np.asarray(vertices)
654-
return (
655-
((self.min < vertices) & (vertices < self.max)).all(axis=1).sum())
655+
with np.errstate(invalid='ignore'):
656+
return (((self.min < vertices) &
657+
(vertices < self.max)).all(axis=1).sum())
656658

657659
def count_overlaps(self, bboxes):
658660
"""

0 commit comments

Comments
 (0)