Fix divide by 0 runtime warning#23430
Conversation
| p1 = (10, 30, 20) | ||
| p2 = (20, 150) | ||
| proj3d._line2d_seg_dist(p0, p0, p2) | ||
| proj3d._line2d_seg_dist(p0, p1, p2) |
There was a problem hiding this comment.
Um, this now accepts a 3d line and a 2d point? I'm not clear what the semantics here is or whether this is desired. At the very least we should document the expected input dimensions for the function.
There was a problem hiding this comment.
This is an internal helper that I think we pulled out.
Given that @scottshambaugh was seeing this warning we are apparently passing in 3D points in practice.
While this is an odd internal wart, I do not think it is worth the effort we have collectively thrown at this function recently!
There was a problem hiding this comment.
My point is that we are doing some ill-defined things in the function. Note that this function is only used in format_coord and I wouldn't be surprised if it's the cause of #22775.
The earlier work #22628 was defensive in only bailing out when both line-defining points were equal in 3d. That does not alter the behavior - it's not making anything worse at least.
I don't know what the correct behavior here should be, but I believe that neglecting the z-direction will add another quirk to the coord determination.
Edit: Rethinking this, since we are anyway only measuring the distance in x, y. This check is not making it worse either. - As little as that is worth.
More generally, I support @anntzer's view that we should stop displaying 3D coords, because we can't get them from a 2d pointer consistently.
This is not making things worse than they are. So ok.
…430-on-v3.5.x Backport PR #23430 on branch v3.5.x (Fix divide by 0 runtime warning)
PR Summary
PR #22624 didn't fix the runtime error popping up when the two points have the same X and Y but differing Z coordinates. This fixes that.
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).Documentation
doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).