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

Skip to content

Avoid division-by-zero in Sketch::Sketch #28707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024
Merged

Avoid division-by-zero in Sketch::Sketch #28707

merged 1 commit into from
Aug 12, 2024

Conversation

jsspencer
Copy link
Contributor

PR summary

An optimization introduced in #24964 introduced a divide-by-zero error when creating a Sketch object 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

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 1023 to 1024
// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry -- thought I'd picked these up. Fixed.

@tacaswell tacaswell added this to the v3.10.0 milestone Aug 12, 2024
@tacaswell
Copy link
Member

The doc failure looks unrelated to me (and I would be is happening on main as well).

@ksunden ksunden merged commit eb342f1 into matplotlib:main Aug 12, 2024
38 of 41 checks passed
@jsspencer jsspencer deleted the fix_sketch_divide_by_zero branch August 12, 2024 21:33
@tacaswell
Copy link
Member

Thank you @jsspencer and congratulations on your first merged PR to Matplotlib 🎉

I hope we hear from you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[Bug]: division-by-zero error in Sketch::Sketch with Agg backend
4 participants