Skip to content

Commit 59b520d

Browse files
committed
Add RuntimeWarning guard.
1 parent 7aed240 commit 59b520d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/mpl_toolkits/mplot3d/proj3d.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ def _line2d_seg_dist(p1, p2, p0):
2222
x01 = np.asarray(p0[0]) - p1[0]
2323
y01 = np.asarray(p0[1]) - p1[1]
2424

25-
u = (x01*x21 + y01*y21) / (x21**2 + y21**2)
26-
u = np.clip(u, 0, 1)
25+
if x21 != 0.0 or y21 != 0.0:
26+
u = (x01*x21 + y01*y21) / (x21**2 + y21**2)
27+
u = np.clip(u, 0, 1)
28+
else:
29+
u = 0.0
2730
d = np.hypot(x01 - u*x21, y01 - u*y21)
2831

2932
return d

0 commit comments

Comments
 (0)