Skip to content

Commit 2716c82

Browse files
authored
Merge pull request #23430 from scottshambaugh/3d_div0_warning
Fix divide by 0 runtime warning
2 parents 8b5516b + e683419 commit 2716c82

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/mpl_toolkits/mplot3d/proj3d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _line2d_seg_dist(p1, p2, p0):
2121

2222
x01 = np.asarray(p0[0]) - p1[0]
2323
y01 = np.asarray(p0[1]) - p1[1]
24-
if np.all(p1 == p2):
24+
if np.all(p1[0:2] == p2[0:2]):
2525
return np.hypot(x01, y01)
2626

2727
x21 = p2[0] - p1[0]

lib/mpl_toolkits/tests/test_mplot3d.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,13 @@ def test_lines_dists():
10111011
def test_lines_dists_nowarning():
10121012
# Smoke test to see that no RuntimeWarning is emitted when two first
10131013
# arguments are the same, see GH#22624
1014-
p0 = (10, 30)
1015-
p1 = (20, 150)
1016-
proj3d._line2d_seg_dist(p0, p0, p1)
1014+
p0 = (10, 30, 50)
1015+
p1 = (10, 30, 20)
1016+
p2 = (20, 150)
1017+
proj3d._line2d_seg_dist(p0, p0, p2)
1018+
proj3d._line2d_seg_dist(p0, p1, p2)
10171019
p0 = np.array(p0)
1018-
proj3d._line2d_seg_dist(p0, p0, p1)
1020+
proj3d._line2d_seg_dist(p0, p0, p2)
10191021

10201022

10211023
def test_autoscale():

0 commit comments

Comments
 (0)