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

Skip to content

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

Merged
ksunden merged 1 commit intomatplotlib:mainfrom
jsspencer:fix_sketch_divide_by_zero
Aug 12, 2024
Merged

Avoid division-by-zero in Sketch::Sketch#28707
ksunden merged 1 commit intomatplotlib:mainfrom
jsspencer:fix_sketch_divide_by_zero

Conversation

@jsspencer
Copy link
Copy Markdown
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
Copy Markdown

@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 thread src/path_converters.h Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@jsspencer jsspencer deleted the fix_sketch_divide_by_zero branch August 12, 2024 21:33
@tacaswell
Copy link
Copy Markdown
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