Avoid division-by-zero in Sketch::Sketch#28707
Avoid division-by-zero in Sketch::Sketch#28707ksunden merged 1 commit intomatplotlib:mainfrom jsspencer:fix_sketch_divide_by_zero
Conversation
There was a problem hiding this comment.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
| // Set derived values to zero if m_length or m_randomness are zero to | ||
| // avoid divide-by-zero errors when a sketch is created but not used. |
There was a problem hiding this comment.
| // Set derived values to zero if m_length or m_randomness are zero to | |
| // avoid divide-by-zero errors when a sketch is created but not used. | |
| // Set derived values to zero if m_length or m_randomness are zero to | |
| // avoid divide-by-zero errors when a sketch is created but not used. |
Don't think c++ code actually cares, but can we stick with spaces rather than tabs?
There was a problem hiding this comment.
Oops, sorry -- thought I'd picked these up. Fixed.
|
The doc failure looks unrelated to me (and I would be is happening on main as well). |
|
Thank you @jsspencer and congratulations on your first merged PR to Matplotlib 🎉 I hope we hear from you again! |
PR summary
An optimization introduced in #24964 introduced a divide-by-zero error when creating a
Sketchobject in cases where some parameters were set to 0. This is normally fine as the sketch is not used in these cases and was only detectable when compiled with-fsanitize=float-divide-by-zero. Avoid these errors by detecting zero and near-zero values passed in and set derived values to 0 in these cases.closes #28669
PR checklist